test_path.py 文件源码

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

项目:zippy 作者: securesystemslab 项目源码 文件源码
def test_implicit_hooks(self):
        # Test that the implicit path hooks are used.
        bad_path = '<path>'
        module = '<module>'
        assert not os.path.exists(bad_path)
        existing_path = tempfile.mkdtemp()
        try:
            with util.import_state():
                nothing = _bootstrap._DefaultPathFinder.find_module(module,
                                                        path=[existing_path])
                self.assertTrue(nothing is None)
                self.assertTrue(existing_path in sys.path_importer_cache)
                result = isinstance(sys.path_importer_cache[existing_path],
                                    imp.NullImporter)
                self.assertFalse(result)
                nothing = _bootstrap._DefaultPathFinder.find_module(module,
                                                            path=[bad_path])
                self.assertTrue(nothing is None)
                self.assertTrue(bad_path in sys.path_importer_cache)
                self.assertTrue(isinstance(sys.path_importer_cache[bad_path],
                                           imp.NullImporter))
        finally:
            os.rmdir(existing_path)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号