Skip to content

Commit 339f260

Browse files
gh-108927: Do not remove tested modules from sys.modules
It breaks import machinery if the test module has submodules used in other tests.
1 parent ad1d6a1 commit 339f260

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

Lib/test/libregrtest/runtest.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,6 @@ def regrtest_runner(result, test_func, ns) -> None:
434434
def _load_run_test(result: TestResult, ns: Namespace) -> None:
435435
# Load the test function, run the test function.
436436
module_name = abs_module_name(result.test_name, ns.testdir)
437-
438-
# Remove the module from sys.module to reload it if it was already imported
439-
sys.modules.pop(module_name, None)
440-
441437
test_mod = importlib.import_module(module_name)
442438

443439
if hasattr(test_mod, "test_main"):
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixed failure for tests running sequentially in the same process when
2+
test_importlib occurs between two other tests that use test_importlib.util.

0 commit comments

Comments
 (0)