MCPcopy Index your code
hub / github.com/python/cpython / load_tests

Function load_tests

Lib/test/test_pdb.py:5199–5247  ·  view source on GitHub ↗
(loader, tests, pattern)

Source from the content-addressed store, hash-verified

5197
5198
5199def 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
5250if __name__ == '__main__':

Callers 1

loadTestsFromModuleMethod · 0.50

Calls 2

setUpPdbBackendFunction · 0.85
addTestMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…