def test_remove_hooks2(self):
"""
As above, but with the new names
"""
example_PY2_check = False
standard_library.install_hooks()
old_meta_path = copy.copy(sys.meta_path)
standard_library.remove_hooks()
standard_library.scrub_future_sys_modules()
if utils.PY2:
self.assertTrue(len(old_meta_path) == len(sys.meta_path) + 1)
else:
self.assertTrue(len(old_meta_path) == len(sys.meta_path))
# An example of fragile import code that we don't want to break:
try:
import builtins
except ImportError:
example_PY2_check = True
if utils.PY2:
self.assertTrue(example_PY2_check)
else:
self.assertFalse(example_PY2_check)
standard_library.install_hooks()
# The import should succeed again now:
import builtins
self.assertTrue(len(old_meta_path) == len(sys.meta_path))
评论列表
文章目录