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