Module existence can be tested inside eggs
(self)
| 86 | sys.modules.pop("egg_module", None) |
| 87 | |
| 88 | def test_shallow_loader(self): |
| 89 | "Module existence can be tested inside eggs" |
| 90 | egg_name = "%s/test_egg.egg" % self.egg_dir |
| 91 | with extend_sys_path(egg_name): |
| 92 | egg_module = import_module("egg_module") |
| 93 | |
| 94 | # An importable child |
| 95 | self.assertTrue(module_has_submodule(egg_module, "good_module")) |
| 96 | mod = import_module("egg_module.good_module") |
| 97 | self.assertEqual(mod.content, "Good Module") |
| 98 | |
| 99 | # A child that exists, but will generate an import error if loaded |
| 100 | self.assertTrue(module_has_submodule(egg_module, "bad_module")) |
| 101 | with self.assertRaises(ImportError): |
| 102 | import_module("egg_module.bad_module") |
| 103 | |
| 104 | # A child that doesn't exist |
| 105 | self.assertFalse(module_has_submodule(egg_module, "no_such_module")) |
| 106 | with self.assertRaises(ImportError): |
| 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" |
nothing calls this directly
no test coverage detected