@@ -603,10 +603,18 @@ def pytest_runtest_logreport(self, report: TestReport) -> None:
603
603
markup = {"yellow" : True }
604
604
else :
605
605
markup = {}
606
+ self ._progress_nodeids_reported .add (rep .nodeid )
606
607
if self .config .get_verbosity (Config .VERBOSITY_TEST_CASES ) <= 0 :
607
608
self ._tw .write (letter , ** markup )
609
+ # When running in xdist, the logreport and logfinish of multiple
610
+ # items are interspersed, e.g. `logreport`, `logreport`,
611
+ # `logfinish`, `logfinish`. To avoid the "past edge" calculation
612
+ # from getting confused and overflowing (#7166), do the past edge
613
+ # printing here and not in logfinish, except for the 100% which
614
+ # should only be printed after all teardowns are finished.
615
+ if self ._show_progress_info and not self ._is_last_item :
616
+ self ._write_progress_information_if_past_edge ()
608
617
else :
609
- self ._progress_nodeids_reported .add (rep .nodeid )
610
618
line = self ._locationline (rep .nodeid , * rep .location )
611
619
running_xdist = hasattr (rep , "node" )
612
620
if not running_xdist :
@@ -648,17 +656,19 @@ def _is_last_item(self) -> bool:
648
656
assert self ._session is not None
649
657
return len (self ._progress_nodeids_reported ) == self ._session .testscollected
650
658
651
- def pytest_runtest_logfinish (self , nodeid : str ) -> None :
659
+ @hookimpl (wrapper = True )
660
+ def pytest_runtestloop (self ) -> Generator [None , object , object ]:
661
+ result = yield
662
+
663
+ # Write the final/100% progress -- deferred until the loop is complete.
652
664
if (
653
665
self .config .get_verbosity (Config .VERBOSITY_TEST_CASES ) <= 0
654
666
and self ._show_progress_info
667
+ and self ._progress_nodeids_reported
655
668
):
656
- self ._progress_nodeids_reported . add ( nodeid )
669
+ self ._write_progress_information_filling_space ( )
657
670
658
- if self ._is_last_item :
659
- self ._write_progress_information_filling_space ()
660
- else :
661
- self ._write_progress_information_if_past_edge ()
671
+ return result
662
672
663
673
def _get_progress_information_message (self ) -> str :
664
674
assert self ._session
0 commit comments