Commit ba089050 authored by Victor Stinner's avatar Victor Stinner

(merge 3.2) Issue #12400: regrtest, force verbose mode to True with option -W

If verbose is False, the output is empty. Fix also a typo in a variable name.
parents d71bd9a9 ea95de75
...@@ -838,29 +838,32 @@ def runtest(test, verbose, quiet, ...@@ -838,29 +838,32 @@ def runtest(test, verbose, quiet,
if use_timeout: if use_timeout:
faulthandler.dump_tracebacks_later(timeout, exit=True) faulthandler.dump_tracebacks_later(timeout, exit=True)
try: try:
support.verbose = verbose # Tell tests to be moderately quiet
if output_on_failure: if output_on_failure:
support.verbose = True
# Reuse the same instance to all calls to runtest(). Some
# tests keep a reference to sys.stdout or sys.stderr
# (eg. test_argparse).
if runtest.stringio is None: if runtest.stringio is None:
# Reuse the same instance to all calls to runtest(). Some
# tests keep a reference to sys.stdout or sys.stderr
# (eg. test_argparse).
runtest.stringio = io.StringIO() runtest.stringio = io.StringIO()
stream = runtest.stringio
orig_stdout = sys.stdout orig_stdout = sys.stdout
orig_stderr = sys.stderr orig_stderr = sys.stderr
try: try:
sys.stdout = runtest.stringio sys.stdout = stream
sys.stderr = runtest.stringio sys.stderr = stream
result = runtest_inner(test, verbose, quiet, huntrleaks, result = runtest_inner(test, verbose, quiet, huntrleaks,
debug, display_failure=False) debug, display_failure=False)
if result[0] == FAILED: if result[0] == FAILED:
output = stringio.getvalue() output = stream.getvalue()
orig_stderr.write(output) orig_stderr.write(output)
orig_stderr.flush() orig_stderr.flush()
finally: finally:
sys.stdout = orig_stdout sys.stdout = orig_stdout
sys.stderr = orig_stderr sys.stderr = orig_stderr
else: else:
support.verbose = verbose # Tell tests to be moderately quiet
result = runtest_inner(test, verbose, quiet, huntrleaks, debug, result = runtest_inner(test, verbose, quiet, huntrleaks, debug,
display_failure=not verbose) display_failure=not verbose)
return result return result
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment