summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/test
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2009-08-30 20:22:21 (GMT)
committerBrett Cannon <bcannon@gmail.com>2009-08-30 20:22:21 (GMT)
commit1c1dcbfd5db9ec3e47ca9ddf28e7c6b87f09eb19 (patch)
treef5c9b6ba568ea86b2c0d29c79021ca050b2e7bfd /Lib/importlib/test
parent82a23fe3925245086460eb7da95bbdc39cd2454a (diff)
downloadcpython-1c1dcbfd5db9ec3e47ca9ddf28e7c6b87f09eb19.zip
cpython-1c1dcbfd5db9ec3e47ca9ddf28e7c6b87f09eb19.tar.gz
cpython-1c1dcbfd5db9ec3e47ca9ddf28e7c6b87f09eb19.tar.bz2
Trying to import a submodule from another module and not a package was raising
AttributeError in importlib when it should be an ImportError. Found when running importlib against test_runpy.
Diffstat (limited to 'Lib/importlib/test')
-rw-r--r--Lib/importlib/test/import_/test_packages.py6
-rw-r--r--Lib/importlib/test/regrtest.py3
2 files changed, 6 insertions, 3 deletions
diff --git a/Lib/importlib/test/import_/test_packages.py b/Lib/importlib/test/import_/test_packages.py
index 1a15ebb..faadc32 100644
--- a/Lib/importlib/test/import_/test_packages.py
+++ b/Lib/importlib/test/import_/test_packages.py
@@ -21,6 +21,12 @@ class ParentModuleTests(unittest.TestCase):
with self.assertRaises(ImportError):
import_util.import_('pkg.module')
+ def test_module_not_package(self):
+ # Try to import a submodule from a non-package should raise ImportError.
+ assert not hasattr(sys, '__path__')
+ with self.assertRaises(ImportError):
+ import_util.import_('sys.no_submodules_here')
+
def test_main():
from test.support import run_unittest
diff --git a/Lib/importlib/test/regrtest.py b/Lib/importlib/test/regrtest.py
index ca27489..f9721c0 100644
--- a/Lib/importlib/test/regrtest.py
+++ b/Lib/importlib/test/regrtest.py
@@ -8,9 +8,6 @@ this script.
XXX FAILING
test_import # execution bit, exception name differing, file name differing
between code and module (?)
- test_runpy # Importing sys.imp.eric raises AttributeError instead of
- ImportError (as does any attempt to import a sub-module
- from a non-package, e.g. tokenize.menotreal)
"""
import importlib