[Python-checkins] cpython (merge 3.2 -> default): (merge 3.2) Issue #12400: regrtest, force verbose mode to True with option -W

victor.stinner python-checkins at python.org
Wed Jun 29 15:38:49 CEST 2011


http://hg.python.org/cpython/rev/561974b760eb
changeset:   71071:561974b760eb
parent:      71069:8897c755633b
parent:      71070:2d07b1b4466a
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Wed Jun 29 15:38:18 2011 +0200
summary:
  (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.

files:
  Lib/test/regrtest.py |  17 ++++++++++-------
  1 files changed, 10 insertions(+), 7 deletions(-)


diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -838,29 +838,32 @@
     if use_timeout:
         faulthandler.dump_tracebacks_later(timeout, exit=True)
     try:
-        support.verbose = verbose  # Tell tests to be moderately quiet
         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:
-                # 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()
+            stream = runtest.stringio
 
             orig_stdout = sys.stdout
             orig_stderr = sys.stderr
             try:
-                sys.stdout = runtest.stringio
-                sys.stderr = runtest.stringio
+                sys.stdout = stream
+                sys.stderr = stream
                 result = runtest_inner(test, verbose, quiet, huntrleaks,
                                        debug, display_failure=False)
                 if result[0] == FAILED:
-                    output = stringio.getvalue()
+                    output = stream.getvalue()
                     orig_stderr.write(output)
                     orig_stderr.flush()
             finally:
                 sys.stdout = orig_stdout
                 sys.stderr = orig_stderr
         else:
+            support.verbose = verbose  # Tell tests to be moderately quiet
             result = runtest_inner(test, verbose, quiet, huntrleaks, debug,
                                    display_failure=not verbose)
         return result

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list