summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2009-10-07 23:54:53 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2009-10-07 23:54:53 (GMT)
commit6bf5a2e85bc549647cd050a5e38e70f81db80c5a (patch)
tree5d107a889966fe9c3fb11da1c5e165bd552be608
parentb090761ec035153ff9ac192a0a17ffd7d3706830 (diff)
downloadcpython-6bf5a2e85bc549647cd050a5e38e70f81db80c5a.zip
cpython-6bf5a2e85bc549647cd050a5e38e70f81db80c5a.tar.gz
cpython-6bf5a2e85bc549647cd050a5e38e70f81db80c5a.tar.bz2
Merged revisions 75279 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r75279 | r.david.murray | 2009-10-07 19:38:55 -0400 (Wed, 07 Oct 2009) | 10 lines 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. ........ ................
-rwxr-xr-xLib/test/regrtest.py15
-rw-r--r--Misc/NEWS3
2 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index e98a99a..0c01cd2 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -598,6 +598,10 @@ def runtest_inner(test, generate, verbose, quiet, test_times,
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 cfp:
sys.stdout = cfp
@@ -622,6 +626,17 @@ def runtest_inner(test, generate, verbose, quiet, test_times,
test_times.append((test_time, test))
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)
diff --git a/Misc/NEWS b/Misc/NEWS
index 4b6ff0b..96ad164 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -79,6 +79,9 @@ Extension Modules
Tests
-----
+- Issue #7058: Added save/restore for argv and os.environ to runtest_inner
+ in regrtest, with warnings if the called test modifies them.
+
- Issue #7042: Fix test_signal (test_itimer_virtual) failure on OS X 10.6.
Build