Skip to content

Commit

Permalink
pythongh-108927: Do not remove tested modules from sys.modules
Browse files Browse the repository at this point in the history
It breaks import machinery if the test module has submodules used in
other tests.
  • Loading branch information
serhiy-storchaka committed Sep 5, 2023
1 parent ad1d6a1 commit 339f260
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 0 additions & 4 deletions Lib/test/libregrtest/runtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,6 @@ def regrtest_runner(result, test_func, ns) -> None:
def _load_run_test(result: TestResult, ns: Namespace) -> None:
# Load the test function, run the test function.
module_name = abs_module_name(result.test_name, ns.testdir)

# Remove the module from sys.module to reload it if it was already imported
sys.modules.pop(module_name, None)

test_mod = importlib.import_module(module_name)

if hasattr(test_mod, "test_main"):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed failure for tests running sequentially in the same process when
test_importlib occurs between two other tests that use test_importlib.util.

0 comments on commit 339f260

Please sign in to comment.