summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_import.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-04-14 18:10:13 (GMT)
committerBrett Cannon <brett@python.org>2012-04-14 18:10:13 (GMT)
commitfd0741555b733f66c0a35c698d0cac5e73010ae0 (patch)
tree739b3aeb0a9d31f49dd334e5f57b5376b20d7dc7 /Lib/test/test_import.py
parentd2cbd9053975d6d6a98adb23b2735b2125ed0626 (diff)
downloadcpython-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_import.py')
-rw-r--r--Lib/test/test_import.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
index bd2da72..87409fc 100644
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -73,6 +73,7 @@ class ImportTests(unittest.TestCase):
if TESTFN in sys.modules:
del sys.modules[TESTFN]
+ importlib.invalidate_caches()
try:
try:
mod = __import__(TESTFN)
@@ -402,6 +403,7 @@ func_filename = func.__code__.co_filename
py_compile.compile(self.file_name, dfile=target)
os.remove(self.file_name)
pyc_file = make_legacy_pyc(self.file_name)
+ importlib.invalidate_caches()
mod = self.import_module()
self.assertEqual(mod.module_filename, pyc_file)
self.assertEqual(mod.code_filename, target)
@@ -509,7 +511,7 @@ class RelativeImportTests(unittest.TestCase):
# Check relative import fails with package set to a non-string
ns = dict(__package__=object())
- self.assertRaises(ValueError, check_relative)
+ self.assertRaises(TypeError, check_relative)
def test_absolute_import_without_future(self):
# If explicit relative import syntax is used, then do not try
@@ -644,6 +646,7 @@ class PycacheTests(unittest.TestCase):
pass
unload('pep3147.foo')
unload('pep3147')
+ importlib.invalidate_caches()
m = __import__('pep3147.foo')
init_pyc = imp.cache_from_source(
os.path.join('pep3147', '__init__.py'))
@@ -666,9 +669,11 @@ class PycacheTests(unittest.TestCase):
pass
with open(os.path.join('pep3147', 'foo.py'), 'w'):
pass
+ importlib.invalidate_caches()
m = __import__('pep3147.foo')
unload('pep3147.foo')
unload('pep3147')
+ importlib.invalidate_caches()
m = __import__('pep3147.foo')
init_pyc = imp.cache_from_source(
os.path.join('pep3147', '__init__.py'))