]> granicus.if.org Git - python/commitdiff
(merge 3.2) Issue #12400: regrtest -W doesn't rerun the tests twice anymore,
authorVictor Stinner <victor.stinner@haypocalc.com>
Wed, 29 Jun 2011 11:04:35 +0000 (13:04 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Wed, 29 Jun 2011 11:04:35 +0000 (13:04 +0200)
but captures the output and displays it on failure instead. regrtest -v doesn't
print the error twice anymore if there is only one error.

1  2 
Lib/test/regrtest.py
Lib/test/test_os.py
Misc/NEWS

index 968b59df5a8af2d03bc38e3d973d232204c72bd8,2929001359aecef67cfea0968406a3f897b7bbab..62d869c41a4d8b31cb4dba670919a9c9e4711b84
@@@ -831,24 -781,29 +831,34 @@@ def runtest(test, verbose, quiet
          PASSED           test passed
      """
  
-     support.verbose = verbose  # Tell tests to be moderately quiet
      if use_resources is not None:
          support.use_resources = use_resources
 +    use_timeout = (timeout is not None)
 +    if use_timeout:
 +        faulthandler.dump_tracebacks_later(timeout, exit=True)
      try:
-         result = runtest_inner(test, verbose, quiet, huntrleaks, debug)
-         if result[0] == FAILED and rerun_failed:
-             cleanup_test_droppings(test, verbose)
-             sys.stdout.flush()
-             sys.stderr.flush()
-             print("Re-running test {} in verbose mode".format(test))
-             runtest(test, True, quiet, huntrleaks, debug, timeout=timeout)
+         if rerun_failed:
+             support.verbose = True
+             orig_stderr = sys.stderr
+             with support.captured_stdout() as stream:
+                 try:
+                     sys.stderr = stream
+                     result = runtest_inner(test, verbose, quiet, huntrleaks,
+                                            debug, display_failure=False)
+                     if result[0] == FAILED:
+                         output = stream.getvalue()
+                         orig_stderr.write(output)
+                         orig_stderr.flush()
+                 finally:
+                     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
      finally:
 +        if use_timeout:
 +            faulthandler.cancel_dump_tracebacks_later()
          cleanup_test_droppings(test, verbose)
  
  # Unit tests are supposed to leave the execution environment unchanged
@@@ -1020,8 -970,13 +1030,9 @@@ class saved_test_environment
          return False
  
  
- def runtest_inner(test, verbose, quiet, huntrleaks=False, debug=False):
+ def runtest_inner(test, verbose, quiet,
+                   huntrleaks=False, debug=False, display_failure=True):
      support.unload(test)
 -    if verbose:
 -        capture_stdout = None
 -    else:
 -        capture_stdout = io.StringIO()
  
      test_time = 0.0
      refleak = False  # True if the test leaked references.
index 13dc337e3e5b8a5dc1c6cae85d07251f098ef2c4,f58a5c1647a3089192a5db793b27b8db0d6ba66b..e075a6b3fc362d79bb1cf327e0a21eb56cf7e0d1
@@@ -40,6 -35,6 +40,7 @@@ class FileTests(unittest.TestCase)
      tearDown = setUp
  
      def test_access(self):
++        self.assertEqual(1,2)
          f = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR)
          os.close(f)
          self.assertTrue(os.access(support.TESTFN, os.W_OK))
diff --cc Misc/NEWS
index 282dc5ac0c67ebb56577108360556b159c5dad5c,51a7d57a3e836f8d3c12518068e75167dbe7fa41..ce31628c52f4b006253eb46e29566b599a924a4a
+++ b/Misc/NEWS
@@@ -924,36 -567,6 +924,40 @@@ Extension Module
  Tests
  -----
  
++- Issue #12400: regrtest -W doesn't rerun the tests twice anymore, but captures
++  the output and displays it on failure instead. regrtest -v doesn't print the
++  error twice anymore if there is only one error.
++
 +- Issue #12141: Install copies of template C module file so that
 +  test_build_ext of test_distutils and test_command_build_ext of
 +  test_packaging are no longer silently skipped when
 +  run outside of a build directory.
 +
 +- Issue #8746: Add additional tests for os.chflags() and os.lchflags().
 +  Patch by Garrett Cooper.
 +
 +- Issue #10736: Fix test_ttk test_widgets failures with Cocoa Tk 8.5.9
 +  2.8 +  on Mac OS X.  (Patch by Ronald Oussoren)
 +
 +- Issue #12057: Add tests for ISO 2022 codecs (iso2022_jp, iso2022_jp_2,
 +  iso2022_kr).
 +
 +- Issue #12180: Fixed a few remaining errors in test_packaging when no
 +  threading.
 +
 +- Issue #12120, #12119: skip a test in packaging and distutils
 +  if sys.dont_write_bytecode is set to True.
 +
 +- Issue #12096: Fix a race condition in test_threading.test_waitfor(). Patch
 +  written by Charles-François Natali.
 +
 +- Issue #11614: import __hello__ prints "Hello World!". Patch written by
 +  Andreas Stührk.
 +
 +- Issue #5723: Improve json tests to be executed with and without accelerations.
 +
 +- Issue #12041: Make test_wait3 more robust.
 +
  - Issue #11873: Change regex in test_compileall to fix occasional failures when
    when the randomly generated temporary path happened to match the regex.