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

Function tearDown

Lib/test/test_pdb.py:5208–5231  ·  view source on GitHub ↗
(test)

Source from the content-addressed store, hash-verified

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(

Callers

nothing calls this directly

Calls 4

_set_event_loop_policyFunction · 0.90
clearBreakpointsMethod · 0.80
stop_traceMethod · 0.45
collectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…