summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_support.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-09-25 20:05:11 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-09-25 20:05:11 (GMT)
commit8dee809410e2d433bb0be5d8a1699736b90db0b5 (patch)
tree896e67b420b872b782084d70b44d957471678139 /Lib/test/test_support.py
parent698acf98fdafd14b1b5ad380e3c56b31ab33a229 (diff)
downloadcpython-8dee809410e2d433bb0be5d8a1699736b90db0b5.zip
cpython-8dee809410e2d433bb0be5d8a1699736b90db0b5.tar.gz
cpython-8dee809410e2d433bb0be5d8a1699736b90db0b5.tar.bz2
Guido points out that sys.__stdout__ is a bit bucket under IDLE. So keep
the local save/modify/restore of sys.stdout, but add machinery so that regrtest can tell test_support the value of sys.stdout at the time regrtest.main() started, and test_support can pass that out later to anyone who needs a "visible" stdout.
Diffstat (limited to 'Lib/test/test_support.py')
-rw-r--r--Lib/test/test_support.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index a07ec10..04a778b 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -21,6 +21,17 @@ class TestSkipped(Error):
verbose = 1 # Flag set to 0 by regrtest.py
use_resources = None # Flag set to [] by regrtest.py
+# _original_stdout is meant to hold stdout at the time regrtest began.
+# This may be "the real" stdout, or IDLE's emulation of stdout, or whatever.
+# The point is to have some flavor of stdout the user can actually see.
+_original_stdout = None
+def record_original_stdout(stdout):
+ global _original_stdout
+ _original_stdout = stdout
+
+def get_original_stdout():
+ return _original_stdout or sys.stdout
+
def unload(name):
try:
del sys.modules[name]
@@ -182,7 +193,7 @@ def run_doctest(module, verbosity=None):
# 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__
+ sys.stdout = get_original_stdout()
try:
f, t = doctest.testmod(module, verbose=verbosity)
if f: