@@ -432,7 +432,7 @@ def hasopt(self, char: str) -> bool:
432432 char = {"xfailed" : "x" , "skipped" : "s" }.get (char , char )
433433 return char in self .reportchars
434434
435- def write_fspath_result (self , nodeid : str , res , ** markup : bool ) -> None :
435+ def write_fspath_result (self , nodeid : str , res : str , ** markup : bool ) -> None :
436436 fspath = self .config .rootpath / nodeid .split ("::" )[0 ]
437437 if self .currentfspath is None or fspath != self .currentfspath :
438438 if self .currentfspath is not None and self ._show_progress_info :
@@ -565,10 +565,11 @@ def pytest_deselected(self, items: Sequence[Item]) -> None:
565565 def pytest_runtest_logstart (
566566 self , nodeid : str , location : Tuple [str , Optional [int ], str ]
567567 ) -> None :
568+ fspath , lineno , domain = location
568569 # Ensure that the path is printed before the
569570 # 1st test of a module starts running.
570571 if self .showlongtestinfo :
571- line = self ._locationline (nodeid , * location )
572+ line = self ._locationline (nodeid , fspath , lineno , domain )
572573 self .write_ensure_prefix (line , "" )
573574 self .flush ()
574575 elif self .showfspath :
@@ -591,7 +592,6 @@ def pytest_runtest_logreport(self, report: TestReport) -> None:
591592 if not letter and not word :
592593 # Probably passed setup/teardown.
593594 return
594- running_xdist = hasattr (rep , "node" )
595595 if markup is None :
596596 was_xfail = hasattr (report , "wasxfail" )
597597 if rep .passed and not was_xfail :
@@ -609,6 +609,7 @@ def pytest_runtest_logreport(self, report: TestReport) -> None:
609609 else :
610610 self ._progress_nodeids_reported .add (rep .nodeid )
611611 line = self ._locationline (rep .nodeid , * rep .location )
612+ running_xdist = hasattr (rep , "node" )
612613 if not running_xdist :
613614 self .write_ensure_prefix (line , word , ** markup )
614615 if rep .skipped or hasattr (report , "wasxfail" ):
@@ -649,38 +650,26 @@ def _is_last_item(self) -> bool:
649650 return len (self ._progress_nodeids_reported ) == self ._session .testscollected
650651
651652 def pytest_runtest_logfinish (self , nodeid : str ) -> None :
652- assert self ._session
653653 if (
654654 self .config .get_verbosity (Config .VERBOSITY_TEST_CASES ) <= 0
655655 and self ._show_progress_info
656656 ):
657- if self ._show_progress_info == "count" :
658- num_tests = self ._session .testscollected
659- progress_length = len (f" [{ num_tests } /{ num_tests } ]" )
660- else :
661- progress_length = len (" [100%]" )
662-
663657 self ._progress_nodeids_reported .add (nodeid )
664658
665659 if self ._is_last_item :
666660 self ._write_progress_information_filling_space ()
667661 else :
668- main_color , _ = self ._get_main_color ()
669- w = self ._width_of_current_line
670- past_edge = w + progress_length + 1 >= self ._screen_width
671- if past_edge :
672- msg = self ._get_progress_information_message ()
673- self ._tw .write (msg + "\n " , ** {main_color : True })
662+ self ._write_progress_information_if_past_edge ()
674663
675664 def _get_progress_information_message (self ) -> str :
676665 assert self ._session
677666 collected = self ._session .testscollected
678667 if self ._show_progress_info == "count" :
679668 if collected :
680- progress = self ._progress_nodeids_reported
669+ progress = len ( self ._progress_nodeids_reported )
681670 counter_format = f"{{:{ len (str (collected ))} d}}"
682671 format_string = f" [{ counter_format } /{{}}]"
683- return format_string .format (len ( progress ) , collected )
672+ return format_string .format (progress , collected )
684673 return f" [ { collected } / { collected } ]"
685674 else :
686675 if collected :
@@ -689,6 +678,20 @@ def _get_progress_information_message(self) -> str:
689678 )
690679 return " [100%]"
691680
681+ def _write_progress_information_if_past_edge (self ) -> None :
682+ w = self ._width_of_current_line
683+ if self ._show_progress_info == "count" :
684+ assert self ._session
685+ num_tests = self ._session .testscollected
686+ progress_length = len (f" [{ num_tests } /{ num_tests } ]" )
687+ else :
688+ progress_length = len (" [100%]" )
689+ past_edge = w + progress_length + 1 >= self ._screen_width
690+ if past_edge :
691+ main_color , _ = self ._get_main_color ()
692+ msg = self ._get_progress_information_message ()
693+ self ._tw .write (msg + "\n " , ** {main_color : True })
694+
692695 def _write_progress_information_filling_space (self ) -> None :
693696 color , _ = self ._get_main_color ()
694697 msg = self ._get_progress_information_message ()
@@ -937,7 +940,7 @@ def mkrel(nodeid: str) -> str:
937940 line += "[" .join (values )
938941 return line
939942
940- # collect_fspath comes from testid which has a "/"-normalized path.
943+ # fspath comes from testid which has a "/"-normalized path.
941944 if fspath :
942945 res = mkrel (nodeid )
943946 if self .verbosity >= 2 and nodeid .split ("::" )[0 ] != fspath .replace (
0 commit comments