mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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.
This commit is contained in:
parent
32fd874afe
commit
8c3f05e9f0
5 changed files with 24 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue