[Python-checkins] bpo-45118: Fix regrtest second summary for re-run tests (GH-28183)

ambv webhook-mailer at python.org
Tue Sep 7 12:21:08 EDT 2021


https://github.com/python/cpython/commit/c4ea45d7d2c02674db2fdb96c7eee89324d2dc64
commit: c4ea45d7d2c02674db2fdb96c7eee89324d2dc64
branch: main
author: Victor Stinner <vstinner at python.org>
committer: ambv <lukasz at langa.pl>
date: 2021-09-07T18:21:00+02:00
summary:

bpo-45118: Fix regrtest second summary for re-run tests (GH-28183)

Fix regrtest second summary when using -w/--verbose2 command line
option: lists re-run tests in the second test summary.

files:
M Lib/test/libregrtest/main.py

diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
index 4dcb639920ba5c..52cc065da115d9 100644
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -66,6 +66,7 @@ def __init__(self):
         self.resource_denieds = []
         self.environment_changed = []
         self.run_no_tests = []
+        self.need_rerun = []
         self.rerun = []
         self.first_result = None
         self.interrupted = False
@@ -116,7 +117,7 @@ def accumulate_result(self, result, rerun=False):
         elif isinstance(result, Failed):
             if not rerun:
                 self.bad.append(test_name)
-                self.rerun.append(result)
+                self.need_rerun.append(result)
         elif isinstance(result, DidNotRun):
             self.run_no_tests.append(test_name)
         elif isinstance(result, Interrupted):
@@ -312,10 +313,12 @@ def rerun_failed_tests(self):
 
         self.log()
         self.log("Re-running failed tests in verbose mode")
-        rerun_list = self.rerun[:]
-        self.rerun = []
+        rerun_list = list(self.need_rerun)
+        self.need_rerun.clear()
         for result in rerun_list:
             test_name = result.name
+            self.rerun.append(test_name)
+
             errors = result.errors or []
             failures = result.failures or []
             error_names = [test_full_name.split(" ")[0] for (test_full_name, *_) in errors]
@@ -397,7 +400,7 @@ def display_result(self):
         if self.rerun:
             print()
             print("%s:" % count(len(self.rerun), "re-run test"))
-            printlist(r.name for r in self.rerun)
+            printlist(self.rerun)
 
         if self.run_no_tests:
             print()



More information about the Python-checkins mailing list