diff options
author | Milan Oberkirch <zvyn@oberkirch.org> | 2017-06-14 21:34:50 (GMT) |
---|---|---|
committer | Brett Cannon <brettcannon@users.noreply.github.com> | 2017-06-14 21:34:50 (GMT) |
commit | 8c3f05e9f0f0b30a3d4a2433e92471794d8258af (patch) | |
tree | 57f6ae60b1701bf4ca4be1f9db1afce1e2bea795 /Lib/test/test_importlib | |
parent | 32fd874afe55e396e3c9a5af35e7bb3d8e0b8f02 (diff) | |
download | cpython-8c3f05e9f0f0b30a3d4a2433e92471794d8258af.zip cpython-8c3f05e9f0f0b30a3d4a2433e92471794d8258af.tar.gz cpython-8c3f05e9f0f0b30a3d4a2433e92471794d8258af.tar.bz2 |
bpo-30436: Raise ModuleNotFoundError for importlib.util.find_spec() when parent isn't a package (GH-1899)
Previously AttributeError was raised, but that's not very reflective of the fact that the requested module can't be found since the specified parent isn't actually a package.
Diffstat (limited to 'Lib/test/test_importlib')
-rw-r--r-- | Lib/test/test_importlib/test_util.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_importlib/test_util.py b/Lib/test/test_importlib/test_util.py index ac18e5c..56a0b0e 100644 --- a/Lib/test/test_importlib/test_util.py +++ b/Lib/test/test_importlib/test_util.py @@ -522,6 +522,12 @@ class FindSpecTests: self.assertNotIn(name, sorted(sys.modules)) self.assertNotIn(fullname, sorted(sys.modules)) + def test_find_submodule_in_module(self): + # ModuleNotFoundError raised when a module is specified as + # a parent instead of a package. + with self.assertRaises(ModuleNotFoundError): + self.util.find_spec('module.name') + (Frozen_FindSpecTests, Source_FindSpecTests |