Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge
  • Loading branch information
sobolevn committed Sep 21, 2023
commit 077ded83a15e60e1bc3d40a6351383e72cfdb118
13 changes: 6 additions & 7 deletions Lib/test/support/import_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,12 @@ def mock_register_at_fork(func):

@contextlib.contextmanager
def ready_to_import(name=None, source=""):
# To fix import cycles:
from test.support import script_helper

# sets up a temporary directory and removes it
# creates the module file
# temporarily clears the module from sys.modules (if any)
# reverts or removes the module when cleaning up
# 1. Sets up a temporary directory and removes it afterwards
# 2. Creates the module file
# 3. Temporarily clears the module from sys.modules (if any)
# 4. Reverts or removes the module when cleaning up
name = name or "spam"
with temp_dir() as tempdir:
Comment thread
sobolevn marked this conversation as resolved.
path = script_helper.make_script(tempdir, name, source)
Expand All @@ -296,5 +295,5 @@ def ready_to_import(name=None, source=""):
finally:
if old_module is not None:
sys.modules[name] = old_module
elif name in sys.modules:
del sys.modules[name]
else:
sys.modules.pop(name, None)
You are viewing a condensed version of this merge commit. You can view the full changes here.