test_path.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:zippy 作者: securesystemslab 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号