summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2009-10-07 23:38:55 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2009-10-07 23:38:55 (GMT)
commit097e51fd49248eb1e53658b8cb7927b5bc0f8ef2 (patch)
tree44d22822e1b7613f54ac81db317460cfeb503afb /Lib
parent56df887b6c1c498af7b5decb3e069c111e4fb520 (diff)
downloadcpython-097e51fd49248eb1e53658b8cb7927b5bc0f8ef2.zip
cpython-097e51fd49248eb1e53658b8cb7927b5bc0f8ef2.tar.gz
cpython-097e51fd49248eb1e53658b8cb7927b5bc0f8ef2.tar.bz2
Merged revisions 75255 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r75255 | r.david.murray | 2009-10-05 13:03:09 -0400 (Mon, 05 Oct 2009) | 3 lines Issue #7058: Added save/restore for argv and os.environ to runtest_inner in regrtest, with warnings if the called test modifies them. ........
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/test/regrtest.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index 157420f..a544d67 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -682,6 +682,10 @@ def runtest_inner(test, verbose, quiet,
refleak = False # True if the test leaked references.
try:
save_stdout = sys.stdout
+ # Save various things that tests may mess up so we can restore
+ # them afterward.
+ save_environ = dict(os.environ)
+ save_argv = sys.argv[:]
try:
if test.startswith('test.'):
abstest = test
@@ -702,6 +706,17 @@ def runtest_inner(test, verbose, quiet,
test_time = time.time() - start_time
finally:
sys.stdout = save_stdout
+ # Restore what we saved if needed, but also complain if the test
+ # changed it so that the test may eventually get fixed.
+ if not os.environ == save_environ:
+ if not quiet:
+ print("Warning: os.environ was modified by", test)
+ os.environ.clear()
+ os.environ.update(save_environ)
+ if not sys.argv == save_argv:
+ if not quiet:
+ print("Warning: argv was modified by", test)
+ sys.argv[:] = save_argv
except support.ResourceDenied as msg:
if not quiet:
print(test, "skipped --", msg)