diff options
author | Brett Cannon <bcannon@gmail.com> | 2009-02-07 01:15:27 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2009-02-07 01:15:27 (GMT) |
commit | 2c318a1390e1a84c78d6f0cacaee1d21cc459234 (patch) | |
tree | 97f2579de870e21766febabe4acaaf53b8cd9eb9 /Lib/importlib/test/test_api.py | |
parent | 887b3f2625404f3835d47a63ae7e0ac4ee638cb6 (diff) | |
download | cpython-2c318a1390e1a84c78d6f0cacaee1d21cc459234.zip cpython-2c318a1390e1a84c78d6f0cacaee1d21cc459234.tar.gz cpython-2c318a1390e1a84c78d6f0cacaee1d21cc459234.tar.bz2 |
Rewrite the code implementing __import__ for importlib. Now it is much simpler
and relies much more on meta path finders to abstract out various parts of
import.
As part of this the semantics for import_module tightened up and now follow
__import__ much more closely (biggest thing is that the 'package' argument must
now already be imported, else a SystemError is raised).
Diffstat (limited to 'Lib/importlib/test/test_api.py')
-rw-r--r-- | Lib/importlib/test/test_api.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/importlib/test/test_api.py b/Lib/importlib/test/test_api.py index 2958adb..8847dc9 100644 --- a/Lib/importlib/test/test_api.py +++ b/Lib/importlib/test/test_api.py @@ -1,6 +1,8 @@ -import unittest -import importlib from . import util +import imp +import importlib +import sys +import unittest class ImportModuleTests(unittest.TestCase): @@ -33,6 +35,7 @@ class ImportModuleTests(unittest.TestCase): relative_name = '.{0}'.format(module_name) with util.mock_modules(pkg_long_name, absolute_name) as mock: with util.import_state(meta_path=[mock]): + importlib.import_module(pkg_name) module = importlib.import_module(relative_name, pkg_name) self.assertEqual(module.__name__, absolute_name) @@ -44,6 +47,7 @@ class ImportModuleTests(unittest.TestCase): name = '{0}.mod'.format(pkg_name) with util.mock_modules(pkg_long_name, name) as mock: with util.import_state(meta_path=[mock]): + importlib.import_module(pkg_name) module = importlib.import_module(name, pkg_name) self.assertEqual(module.__name__, name) |