aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_importlib/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_importlib/util.py')
-rw-r--r--Lib/test/test_importlib/util.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_importlib/util.py b/Lib/test/test_importlib/util.py
index b0badebc2b8..196ea1c9d4d 100644
--- a/Lib/test/test_importlib/util.py
+++ b/Lib/test/test_importlib/util.py
@@ -320,6 +320,17 @@ def ensure_bytecode_path(bytecode_path):
@contextlib.contextmanager
+def temporary_pycache_prefix(prefix):
+ """Adjust and restore sys.pycache_prefix."""
+ _orig_prefix = sys.pycache_prefix
+ sys.pycache_prefix = prefix
+ try:
+ yield
+ finally:
+ sys.pycache_prefix = _orig_prefix
+
+
+@contextlib.contextmanager
def create_modules(*names):
"""Temporarily create each named module with an attribute (named 'attr')
that contains the name passed into the context manager that caused the