def test_importlib_import_relative_pkg_bytecode(self):
"""Verify that package is importable relatively"""
print_importers()
assert __package__
# need globals to handle relative imports
# __import__ checks sys.modules by itself
# but the test is not reflecting anything if we use the already loaded module.
if sys.modules.get(__package__ + '.pkg.bytecode'):
raise unittest.SkipTest("module previously loaded".format(__package__ + '.pkg.bytecode'))
else:
pkg = importlib.__import__('pkg.bytecode', globals=globals(), level=1)
test_mod = pkg.bytecode
self.assertTrue(test_mod is not None)
self.assertTrue(test_mod.TestClassInBytecode is not None)
self.assertTrue(callable(test_mod.TestClassInBytecode))
# TODO : implement some differences and check we get them...
if hasattr(importlib, 'reload'): # recent version of importlib
# attempting to reload
importlib.reload(test_mod)
else:
pass
test_filefinder2_importlib_import.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录