From d82dc7c7b5162d5c5d30bb0e803b4248d6d16162 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 11 Nov 2024 10:08:42 +0300 Subject: [PATCH] Address review --- Lib/test/libregrtest/main.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py index ac12157809dbc2..986952888cd559 100644 --- a/Lib/test/libregrtest/main.py +++ b/Lib/test/libregrtest/main.py @@ -456,6 +456,11 @@ def finalize_tests(self, coverage: trace.CoverageResults | None) -> None: self.results.write_junit(self.junit_filename) def display_summary(self) -> None: + if self.first_runtests is None: + raise ValueError( + "Should never call `display_summary()` before calling `_run_test()`" + ) + duration = time.perf_counter() - self.logger.start_time filtered = bool(self.match_tests) @@ -463,9 +468,6 @@ def display_summary(self) -> None: print() print("Total duration: %s" % format_duration(duration)) - assert self.first_runtests, ( - "Should never call `display_summary()` before calling `_run_test()`" - ) self.results.display_summary(self.first_runtests, filtered) # Result @@ -717,9 +719,10 @@ def _init(self): @property def tmp_dir(self) -> StrPath: - assert self._tmp_dir is not None, ( - "Should never use `.tmp_dir` before calling `.main()`" - ) + if self._tmp_dir is None: + raise ValueError( + "Should never use `.tmp_dir` before calling `.main()`" + ) return self._tmp_dir def main(self, tests: TestList | None = None) -> NoReturn: