def test_path_importer_cache_has_None(self):
# Test that the default hook is used when sys.path_importer_cache
# contains None for a path.
module = '<test module>'
importer = util.mock_modules(module)
path = '<test path>'
# XXX Not blackbox.
original_hook = _bootstrap._DEFAULT_PATH_HOOK
mock_hook = import_util.mock_path_hook(path, importer=importer)
_bootstrap._DEFAULT_PATH_HOOK = mock_hook
try:
with util.import_state(path_importer_cache={path: None}):
loader = _bootstrap._DefaultPathFinder.find_module(module,
path=[path])
self.assertTrue(loader is importer)
finally:
_bootstrap._DEFAULT_PATH_HOOK = original_hook
评论列表
文章目录