summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-09-25 19:13:20 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-09-25 19:13:20 (GMT)
commit342ca75d9552ff5c606c465d1392a32e44257fe5 (patch)
tree5d063062146708903e0911efdfe3da2a5412c31b /Lib
parent5055545fc06adcaa0cdeed69b317f917d9651749 (diff)
downloadcpython-342ca75d9552ff5c606c465d1392a32e44257fe5.zip
cpython-342ca75d9552ff5c606c465d1392a32e44257fe5.tar.gz
cpython-342ca75d9552ff5c606c465d1392a32e44257fe5.tar.bz2
Get rid of the increasingly convoluted global tricks w/ sys.stdout, in
favor of local save/modify/restore. The test suite should run fine again.
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/test/regrtest.py4
-rw-r--r--Lib/test/test_support.py36
2 files changed, 12 insertions, 28 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index d13ff4c..ab58828 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -287,7 +287,7 @@ def runtest(test, generate, verbose, quiet, testdir = None):
else:
cfp = StringIO.StringIO()
try:
- sys.save_stdout = sys.stdout
+ save_stdout = sys.stdout
try:
if cfp:
sys.stdout = cfp
@@ -301,7 +301,7 @@ def runtest(test, generate, verbose, quiet, testdir = None):
if indirect_test is not None:
indirect_test()
finally:
- sys.stdout = sys.save_stdout
+ sys.stdout = save_stdout
except (ImportError, test_support.TestSkipped), msg:
if not quiet:
print "test", test, "skipped --", msg
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index 5a5e33c..a07ec10 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -2,8 +2,6 @@
import sys
-sys.save_stdout = sys.stdout
-
class Error(Exception):
"""Base class for regression test exceptions."""
@@ -23,26 +21,6 @@ class TestSkipped(Error):
verbose = 1 # Flag set to 0 by regrtest.py
use_resources = None # Flag set to [] by regrtest.py
-# _output_comparison controls whether regrtest will try to compare stdout
-# with an expected-output file. For straight regrtests, it should.
-# The doctest driver resets this flag by calling deny_output_comparison().
-# Note that this control is in addition to verbose mode: output will be
-# compared if and only if _output_comparison is true and verbose mode is
-# not in effect.
-_output_comparison = 1
-
-def deny_output_comparison():
- global _output_comparison
- _output_comparison = 0
- sys.stdout = sys.save_stdout
-
-# regrtest's interface to _output_comparison.
-def output_comparison_denied():
- global _output_comparison
- denied = not _output_comparison
- _output_comparison = 1
- return denied
-
def unload(name):
try:
del sys.modules[name]
@@ -201,7 +179,13 @@ def run_doctest(module, verbosity=None):
else:
verbosity = None
- deny_output_comparison()
- f, t = doctest.testmod(module, verbose=verbosity)
- if f:
- raise TestFailed("%d of %d doctests failed" % (f, t))
+ # Direct doctest output (normally just errors) to real stdout; doctest
+ # output shouldn't be compared by regrtest.
+ save_stdout = sys.stdout
+ sys.stdout = sys.__stdout__
+ try:
+ f, t = doctest.testmod(module, verbose=verbosity)
+ if f:
+ raise TestFailed("%d of %d doctests failed" % (f, t))
+ finally:
+ sys.stdout = save_stdout