(loader, tests, pattern)
| 5197 | |
| 5198 | |
| 5199 | def load_tests(loader, tests, pattern): |
| 5200 | from test import test_pdb |
| 5201 | |
| 5202 | def setUpPdbBackend(backend): |
| 5203 | def setUp(test): |
| 5204 | import pdb |
| 5205 | pdb.set_default_backend(backend) |
| 5206 | return setUp |
| 5207 | |
| 5208 | def tearDown(test): |
| 5209 | # Ensure that asyncio state has been cleared at the end of the test. |
| 5210 | # This prevents a "test altered the execution environment" warning if |
| 5211 | # asyncio features are used. |
| 5212 | _set_event_loop_policy(None) |
| 5213 | |
| 5214 | # A doctest of pdb could have residues. For example, pdb could still |
| 5215 | # be running, or breakpoints might be left uncleared. These residues |
| 5216 | # could potentially interfere with the following test, especially |
| 5217 | # when we switch backends. Here we clear all the residues to restore |
| 5218 | # to its pre-test state. |
| 5219 | |
| 5220 | # clear all the breakpoints left |
| 5221 | import bdb |
| 5222 | bdb.Breakpoint.clearBreakpoints() |
| 5223 | |
| 5224 | # Stop tracing and clear the pdb instance cache |
| 5225 | if pdb.Pdb._last_pdb_instance: |
| 5226 | pdb.Pdb._last_pdb_instance.stop_trace() |
| 5227 | pdb.Pdb._last_pdb_instance = None |
| 5228 | |
| 5229 | # If garbage objects are collected right after we start tracing, we |
| 5230 | # could stop at __del__ of the object which would fail the test. |
| 5231 | gc.collect() |
| 5232 | |
| 5233 | tests.addTest( |
| 5234 | doctest.DocTestSuite( |
| 5235 | test_pdb, |
| 5236 | setUp=setUpPdbBackend('monitoring'), |
| 5237 | tearDown=tearDown, |
| 5238 | ) |
| 5239 | ) |
| 5240 | tests.addTest( |
| 5241 | doctest.DocTestSuite( |
| 5242 | test_pdb, |
| 5243 | setUp=setUpPdbBackend('settrace'), |
| 5244 | tearDown=tearDown, |
| 5245 | ) |
| 5246 | ) |
| 5247 | return tests |
| 5248 | |
| 5249 | |
| 5250 | if __name__ == '__main__': |
no test coverage detected
searching dependent graphs…