(result: TestResult, runtests: RunTests)
| 149 | |
| 150 | |
| 151 | def _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 | |
| 188 | def _runtest_env_changed_exc(result: TestResult, runtests: RunTests, |
no test coverage detected
searching dependent graphs…