diff options
author | Brett Cannon <brett@python.org> | 2012-04-14 18:10:13 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-04-14 18:10:13 (GMT) |
commit | fd0741555b733f66c0a35c698d0cac5e73010ae0 (patch) | |
tree | 739b3aeb0a9d31f49dd334e5f57b5376b20d7dc7 /Lib/test/test_runpy.py | |
parent | d2cbd9053975d6d6a98adb23b2735b2125ed0626 (diff) | |
download | cpython-fd0741555b733f66c0a35c698d0cac5e73010ae0.zip cpython-fd0741555b733f66c0a35c698d0cac5e73010ae0.tar.gz cpython-fd0741555b733f66c0a35c698d0cac5e73010ae0.tar.bz2 |
Issue #2377: Make importlib the implementation of __import__().
importlib._bootstrap is now frozen into Python/importlib.h and stored
as _frozen_importlib in sys.modules. Py_Initialize() loads the frozen
code along with sys and imp and then uses _frozen_importlib._install()
to set builtins.__import__() w/ _frozen_importlib.__import__().
Diffstat (limited to 'Lib/test/test_runpy.py')
-rw-r--r-- | Lib/test/test_runpy.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py index 2cede19..de44df0 100644 --- a/Lib/test/test_runpy.py +++ b/Lib/test/test_runpy.py @@ -5,6 +5,7 @@ import os.path import sys import re import tempfile +import importlib import py_compile from test.support import ( forget, make_legacy_pyc, run_unittest, unload, verbose, no_tracing, @@ -172,11 +173,13 @@ class RunModuleTest(unittest.TestCase): self.assertIn("x", d1) self.assertEqual(d1["x"], 1) del d1 # Ensure __loader__ entry doesn't keep file open + importlib.invalidate_caches() __import__(mod_name) os.remove(mod_fname) make_legacy_pyc(mod_fname) unload(mod_name) # In case loader caches paths if verbose: print("Running from compiled:", mod_name) + importlib.invalidate_caches() d2 = run_module(mod_name) # Read from bytecode self.assertIn("x", d2) self.assertEqual(d2["x"], 1) @@ -196,11 +199,13 @@ class RunModuleTest(unittest.TestCase): self.assertIn("x", d1) self.assertTrue(d1["x"] == 1) del d1 # Ensure __loader__ entry doesn't keep file open + importlib.invalidate_caches() __import__(mod_name) os.remove(mod_fname) make_legacy_pyc(mod_fname) unload(mod_name) # In case loader caches paths if verbose: print("Running from compiled:", pkg_name) + importlib.invalidate_caches() d2 = run_module(pkg_name) # Read from bytecode self.assertIn("x", d2) self.assertTrue(d2["x"] == 1) @@ -250,11 +255,13 @@ from ..uncle.cousin import nephew self.assertIn("sibling", d1) self.assertIn("nephew", d1) del d1 # Ensure __loader__ entry doesn't keep file open + importlib.invalidate_caches() __import__(mod_name) os.remove(mod_fname) make_legacy_pyc(mod_fname) unload(mod_name) # In case the loader caches paths if verbose: print("Running from compiled:", mod_name) + importlib.invalidate_caches() d2 = run_module(mod_name, run_name=run_name) # Read from bytecode self.assertIn("__package__", d2) self.assertTrue(d2["__package__"] == pkg_name) |