MCPcopy
hub / github.com/django/django / test_deep_loader

Method test_deep_loader

tests/utils_tests/test_module_loading.py:109–128  ·  view source on GitHub ↗

Modules deep inside an egg can still be tested for existence

(self)

Source from the content-addressed store, hash-verified

107 import_module("egg_module.no_such_module")
108
109 def test_deep_loader(self):
110 "Modules deep inside an egg can still be tested for existence"
111 egg_name = "%s/test_egg.egg" % self.egg_dir
112 with extend_sys_path(egg_name):
113 egg_module = import_module("egg_module.sub1.sub2")
114
115 # An importable child
116 self.assertTrue(module_has_submodule(egg_module, "good_module"))
117 mod = import_module("egg_module.sub1.sub2.good_module")
118 self.assertEqual(mod.content, "Deep Good Module")
119
120 # A child that exists, but will generate an import error if loaded
121 self.assertTrue(module_has_submodule(egg_module, "bad_module"))
122 with self.assertRaises(ImportError):
123 import_module("egg_module.sub1.sub2.bad_module")
124
125 # A child that doesn't exist
126 self.assertFalse(module_has_submodule(egg_module, "no_such_module"))
127 with self.assertRaises(ImportError):
128 import_module("egg_module.sub1.sub2.no_such_module")
129
130
131class ModuleImportTests(SimpleTestCase):

Callers

nothing calls this directly

Calls 2

extend_sys_pathFunction · 0.90
module_has_submoduleFunction · 0.90

Tested by

no test coverage detected