Skip to content

Commit

Permalink
pythongh-115490: Work around test.support.interpreters.channels not h…
Browse files Browse the repository at this point in the history
…andling unloading (python#115515)

Work around test.support.interpreters.channels not handling unloading, which
regrtest does when running tests sequentially, by explicitly skipping the
unloading of test.support.interpreters and its submodules.

This can be rolled back once test.support.interpreters.channels supports
unloading, if we are keeping sequential runs in the same process around.
  • Loading branch information
Yhg1s authored Feb 15, 2024
1 parent a0149fa commit b0e5c35
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Lib/test/libregrtest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,15 @@ def run_tests_sequentially(self, runtests) -> None:

result = self.run_test(test_name, runtests, tracer)

# Unload the newly imported test modules (best effort finalization)
# Unload the newly imported test modules (best effort
# finalization). To work around gh-115490, don't unload
# test.support.interpreters and its submodules even if they
# weren't loaded before.
keep = "test.support.interpreters"
new_modules = [module for module in sys.modules
if module not in save_modules and
module.startswith(("test.", "test_"))]
module.startswith(("test.", "test_"))
and not module.startswith(keep)]
for module in new_modules:
sys.modules.pop(module, None)
# Remove the attribute of the parent module.
Expand Down

0 comments on commit b0e5c35

Please sign in to comment.