@@ -391,7 +391,7 @@ def __init__(self, config: Config, file: TextIO | None = None) -> None:
391
391
self ._progress_nodeids_reported : set [str ] = set ()
392
392
self ._timing_nodeids_reported : set [str ] = set ()
393
393
self ._show_progress_info = self ._determine_show_progress_info ()
394
- self ._collect_report_last_write : float | None = None
394
+ self ._collect_report_last_write = timing . Instant ()
395
395
self ._already_displayed_warnings : int | None = None
396
396
self ._keyboardinterrupt_memo : ExceptionRepr | None = None
397
397
@@ -769,7 +769,6 @@ def pytest_collection(self) -> None:
769
769
if self .isatty :
770
770
if self .config .option .verbose >= 0 :
771
771
self .write ("collecting ... " , flush = True , bold = True )
772
- self ._collect_report_last_write = timing .perf_counter ()
773
772
elif self .config .option .verbose >= 1 :
774
773
self .write ("collecting ... " , flush = True , bold = True )
775
774
@@ -788,14 +787,13 @@ def report_collect(self, final: bool = False) -> None:
788
787
return
789
788
790
789
if not final :
791
- # Only write "collecting" report every 0.5s.
792
- t = timing .perf_counter ()
790
+ # Only write the "collecting" report every `REPORT_COLLECTING_RESOLUTION`.
793
791
if (
794
- self ._collect_report_last_write is not None
795
- and self . _collect_report_last_write > t - REPORT_COLLECTING_RESOLUTION
792
+ self ._collect_report_last_write . elapsed (). seconds
793
+ < REPORT_COLLECTING_RESOLUTION
796
794
):
797
795
return
798
- self ._collect_report_last_write = t
796
+ self ._collect_report_last_write = timing . Instant ()
799
797
800
798
errors = len (self .stats .get ("error" , []))
801
799
skipped = len (self .stats .get ("skipped" , []))
@@ -823,7 +821,7 @@ def report_collect(self, final: bool = False) -> None:
823
821
@hookimpl (trylast = True )
824
822
def pytest_sessionstart (self , session : Session ) -> None :
825
823
self ._session = session
826
- self ._sessionstarttime = timing .perf_counter ()
824
+ self ._session_start = timing .Instant ()
827
825
if not self .showheader :
828
826
return
829
827
self .write_sep ("=" , "test session starts" , bold = True )
@@ -1202,7 +1200,7 @@ def summary_stats(self) -> None:
1202
1200
if self .verbosity < - 1 :
1203
1201
return
1204
1202
1205
- session_duration = timing . perf_counter () - self . _sessionstarttime
1203
+ session_duration = self . _session_start . elapsed ()
1206
1204
(parts , main_color ) = self .build_summary_stats_line ()
1207
1205
line_parts = []
1208
1206
@@ -1217,7 +1215,7 @@ def summary_stats(self) -> None:
1217
1215
msg = ", " .join (line_parts )
1218
1216
1219
1217
main_markup = {main_color : True }
1220
- duration = f" in { format_session_duration (session_duration )} "
1218
+ duration = f" in { format_session_duration (session_duration . seconds )} "
1221
1219
duration_with_markup = self ._tw .markup (duration , ** main_markup )
1222
1220
if display_sep :
1223
1221
fullwidth += len (duration_with_markup ) - len (duration )
0 commit comments