mirror of https://github.com/python/cpython.git
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:
commit
05d34fc953
|
@ -1298,16 +1298,9 @@ def run_doctest(module, verbosity=None):
|
||||||
else:
|
else:
|
||||||
verbosity = None
|
verbosity = None
|
||||||
|
|
||||||
# Direct doctest output (normally just errors) to real stdout; doctest
|
f, t = doctest.testmod(module, verbose=verbosity)
|
||||||
# output shouldn't be compared by regrtest.
|
if f:
|
||||||
save_stdout = sys.stdout
|
raise TestFailed("%d of %d doctests failed" % (f, t))
|
||||||
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:
|
if verbose:
|
||||||
print('doctest (%s) ... %d tests with zero failures' %
|
print('doctest (%s) ... %d tests with zero failures' %
|
||||||
(module.__name__, t))
|
(module.__name__, t))
|
||||||
|
|
Loading…
Reference in New Issue