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

Function _load_run_test

Lib/test/libregrtest/single.py:151–185  ·  view source on GitHub ↗
(result: TestResult, runtests: RunTests)

Source from the content-addressed store, hash-verified

149
150
151def _load_run_test(result: TestResult, runtests: RunTests) -> None:
152 # Load the test module and run the tests.
153 test_name = result.test_name
154 module_name = abs_module_name(test_name, runtests.test_dir)
155 test_mod = importlib.import_module(module_name)
156
157 if hasattr(test_mod, "test_main"):
158 # https://github.com/python/cpython/issues/89392
159 raise Exception(f"Module {test_name} defines test_main() which "
160 f"is no longer supported by regrtest")
161 def test_func():
162 return run_unittest(test_mod, runtests)
163
164 try:
165 regrtest_runner(result, test_func, runtests)
166 finally:
167 # First kill any dangling references to open files etc.
168 # This can also issue some ResourceWarnings which would otherwise get
169 # triggered during the following test run, and possibly produce
170 # failures.
171 support.gc_collect()
172
173 remove_testfn(test_name, runtests.verbose)
174
175 if gc.garbage:
176 support.environment_altered = True
177 print_warning(f"{test_name} created {len(gc.garbage)} "
178 f"uncollectable object(s)")
179
180 # move the uncollectable objects somewhere,
181 # so we don't see them again
182 GC_GARBAGE.extend(gc.garbage)
183 gc.garbage.clear()
184
185 support.reap_children()
186
187
188def _runtest_env_changed_exc(result: TestResult, runtests: RunTests,

Callers 1

_runtest_env_changed_excFunction · 0.85

Calls 7

abs_module_nameFunction · 0.85
regrtest_runnerFunction · 0.85
remove_testfnFunction · 0.85
print_warningFunction · 0.70
import_moduleMethod · 0.45
extendMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…