Issue #12400: test.support.run_doctest() doesn't change sys.stdout anymore

regrtest doesn't check that tests doesn't write something to stdout anymore.

Don't replace sys.stdout by the original sys.stdout to be able to capture the
output for regrtest -W.
This commit is contained in:
Victor Stinner 2011-06-29 15:52:46 +02:00
parent ea95de75dd
commit bddc4d4607
1 changed files with 3 additions and 10 deletions

View File

@ -1230,16 +1230,9 @@ def run_doctest(module, verbosity=None):
else:
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 = get_original_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
if verbose:
print('doctest (%s) ... %d tests with zero failures' %
(module.__name__, t))