diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py index dcbcc6790c68d8..2f8e5ee86742b9 100644 --- a/Lib/test/libregrtest/main.py +++ b/Lib/test/libregrtest/main.py @@ -393,17 +393,19 @@ def run_tests_sequentially(self, runtests: RunTests) -> None: msg += " (timeout: %s)" % format_duration(runtests.timeout) self.log(msg) - previous_test = None tests_iter = runtests.iter_tests() for test_index, test_name in enumerate(tests_iter, 1): - start_time = time.perf_counter() + result = self.run_test(test_name, runtests, tracer) - text = test_name - if previous_test: - text = '%s -- %s' % (text, previous_test) - self.logger.display_progress(test_index, text) + text = str(result) + if ( + result.duration + and result.duration >= PROGRESS_MIN_TIME + and not self.pgo + ): + text += f" ({format_duration(result.duration)})" - result = self.run_test(test_name, runtests, tracer) + self.logger.display_progress(test_index, text) # Unload the newly imported test modules (best effort finalization) new_modules = [module for module in sys.modules @@ -421,17 +423,6 @@ def run_tests_sequentially(self, runtests: RunTests) -> None: if result.must_stop(self.fail_fast, self.fail_env_changed): break - previous_test = str(result) - test_time = time.perf_counter() - start_time - if test_time >= PROGRESS_MIN_TIME: - previous_test = "%s in %s" % (previous_test, format_duration(test_time)) - elif result.state == State.PASSED: - # be quiet: say nothing if the test passed shortly - previous_test = None - - if previous_test: - print(previous_test) - def get_state(self) -> str: state = self.results.get_state(self.fail_env_changed) if self.first_state: diff --git a/Misc/NEWS.d/next/Tests/2025-01-27-16-22-23.gh-issue-129363.HzJPzC.rst b/Misc/NEWS.d/next/Tests/2025-01-27-16-22-23.gh-issue-129363.HzJPzC.rst new file mode 100644 index 00000000000000..b1c4b772d416ee --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2025-01-27-16-22-23.gh-issue-129363.HzJPzC.rst @@ -0,0 +1 @@ +Added colored printing for ``python -m test`` without the ``-j`` flag.