def test_importlib_import_class_from_relative_pkg(self):
"""Verify that message class 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'):
raise unittest.SkipTest("module previously loaded".format(__package__ + '.pkg'))
else:
pkg = importlib.__import__('pkg', globals=globals(), level=1)
test_class_in_subpkg = pkg.TestClassInSubPkg
self.assertTrue(test_class_in_subpkg is not None)
self.assertTrue(callable(test_class_in_subpkg))
# TODO : implement some differences and check we get them...
if hasattr(importlib, 'reload'): # recent version of importlib
# attempting to reload
importlib.reload(pkg)
else:
pass
test_filefinder2_importlib_import.py 文件源码
python
阅读 20
收藏 0
点赞 0
评论 0
评论列表
文章目录