mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #28241 -- Allowed module_has_submodule()'s module_name arg to be a dotted path.
This commit is contained in:
parent
af69f14e7b
commit
f6bd00131e
4 changed files with 21 additions and 1 deletions
0
tests/utils_tests/test_module/child_module/__init__.py
Normal file
0
tests/utils_tests/test_module/child_module/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
content = 'Grandchild Module'
|
|
@ -48,6 +48,18 @@ class DefaultLoader(unittest.TestCase):
|
|||
with self.assertRaises(ImportError):
|
||||
import_module('utils_tests.test_no_submodule.anything')
|
||||
|
||||
def test_has_sumbodule_with_dotted_path(self):
|
||||
"""Nested module existence can be tested."""
|
||||
test_module = import_module('utils_tests.test_module')
|
||||
# A grandchild that exists.
|
||||
self.assertIs(module_has_submodule(test_module, 'child_module.grandchild_module'), True)
|
||||
# A grandchild that doesn't exist.
|
||||
self.assertIs(module_has_submodule(test_module, 'child_module.no_such_module'), False)
|
||||
# A grandchild whose parent doesn't exist.
|
||||
self.assertIs(module_has_submodule(test_module, 'no_such_module.grandchild_module'), False)
|
||||
# A grandchild whose parent is not a package.
|
||||
self.assertIs(module_has_submodule(test_module, 'good_module.no_such_module'), False)
|
||||
|
||||
|
||||
class EggLoader(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue