diff options
author | Brett Cannon <bcannon@gmail.com> | 2010-02-19 15:57:10 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2010-02-19 15:57:10 (GMT) |
commit | 055470a2279e34f7652f50fc7e549b3ec0ce5ce6 (patch) | |
tree | f6da1dfd406e4ec99c040b0629b9d635e42a252b | |
parent | 5e15efa967274ddb1c3195513d5c9c668fd85cfc (diff) | |
download | cpython-055470a2279e34f7652f50fc7e549b3ec0ce5ce6.zip cpython-055470a2279e34f7652f50fc7e549b3ec0ce5ce6.tar.gz cpython-055470a2279e34f7652f50fc7e549b3ec0ce5ce6.tar.bz2 |
Check that sys.path_hooks and __import__ are not changed by tests.
-rwxr-xr-x | Lib/test/regrtest.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index 551158c..33a2248 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -779,7 +779,7 @@ class saved_test_environment: # the corresponding method names. resources = ('sys.argv', 'cwd', 'sys.stdin', 'sys.stdout', 'sys.stderr', - 'os.environ', 'sys.path') + 'os.environ', 'sys.path', 'sys.path_hooks', '__import__') def get_sys_argv(self): return id(sys.argv), sys.argv, sys.argv[:] @@ -820,6 +820,17 @@ class saved_test_environment: sys.path = saved_path[1] sys.path[:] = saved_path[2] + def get_sys_path_hooks(self): + return id(sys.path_hooks), sys.path_hooks, sys.path_hooks[:] + def restore_sys_path_hooks(self, saved_hooks): + sys.path_hooks = saved_hooks[1] + sys.path_hooks[:] = saved_hooks[2] + + def get___import__(self): + return __builtins__.__import__ + def restore___import__(self, import_): + __builtins__.__import__ = import_ + def resource_info(self): for name in self.resources: method_suffix = name.replace('.', '_') |