@@ -432,7 +432,7 @@ def hasopt(self, char: str) -> bool:
432
432
char = {"xfailed" : "x" , "skipped" : "s" }.get (char , char )
433
433
return char in self .reportchars
434
434
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 :
436
436
fspath = self .config .rootpath / nodeid .split ("::" )[0 ]
437
437
if self .currentfspath is None or fspath != self .currentfspath :
438
438
if self .currentfspath is not None and self ._show_progress_info :
@@ -565,10 +565,11 @@ def pytest_deselected(self, items: Sequence[Item]) -> None:
565
565
def pytest_runtest_logstart (
566
566
self , nodeid : str , location : Tuple [str , Optional [int ], str ]
567
567
) -> None :
568
+ fspath , lineno , domain = location
568
569
# Ensure that the path is printed before the
569
570
# 1st test of a module starts running.
570
571
if self .showlongtestinfo :
571
- line = self ._locationline (nodeid , * location )
572
+ line = self ._locationline (nodeid , fspath , lineno , domain )
572
573
self .write_ensure_prefix (line , "" )
573
574
self .flush ()
574
575
elif self .showfspath :
@@ -591,7 +592,6 @@ def pytest_runtest_logreport(self, report: TestReport) -> None:
591
592
if not letter and not word :
592
593
# Probably passed setup/teardown.
593
594
return
594
- running_xdist = hasattr (rep , "node" )
595
595
if markup is None :
596
596
was_xfail = hasattr (report , "wasxfail" )
597
597
if rep .passed and not was_xfail :
@@ -609,6 +609,7 @@ def pytest_runtest_logreport(self, report: TestReport) -> None:
609
609
else :
610
610
self ._progress_nodeids_reported .add (rep .nodeid )
611
611
line = self ._locationline (rep .nodeid , * rep .location )
612
+ running_xdist = hasattr (rep , "node" )
612
613
if not running_xdist :
613
614
self .write_ensure_prefix (line , word , ** markup )
614
615
if rep .skipped or hasattr (report , "wasxfail" ):
@@ -649,38 +650,26 @@ def _is_last_item(self) -> bool:
649
650
return len (self ._progress_nodeids_reported ) == self ._session .testscollected
650
651
651
652
def pytest_runtest_logfinish (self , nodeid : str ) -> None :
652
- assert self ._session
653
653
if (
654
654
self .config .get_verbosity (Config .VERBOSITY_TEST_CASES ) <= 0
655
655
and self ._show_progress_info
656
656
):
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
-
663
657
self ._progress_nodeids_reported .add (nodeid )
664
658
665
659
if self ._is_last_item :
666
660
self ._write_progress_information_filling_space ()
667
661
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 ()
674
663
675
664
def _get_progress_information_message (self ) -> str :
676
665
assert self ._session
677
666
collected = self ._session .testscollected
678
667
if self ._show_progress_info == "count" :
679
668
if collected :
680
- progress = self ._progress_nodeids_reported
669
+ progress = len ( self ._progress_nodeids_reported )
681
670
counter_format = f"{{:{ len (str (collected ))} d}}"
682
671
format_string = f" [{ counter_format } /{{}}]"
683
- return format_string .format (len ( progress ) , collected )
672
+ return format_string .format (progress , collected )
684
673
return f" [ { collected } / { collected } ]"
685
674
else :
686
675
if collected :
@@ -689,6 +678,20 @@ def _get_progress_information_message(self) -> str:
689
678
)
690
679
return " [100%]"
691
680
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
+
692
695
def _write_progress_information_filling_space (self ) -> None :
693
696
color , _ = self ._get_main_color ()
694
697
msg = self ._get_progress_information_message ()
@@ -937,7 +940,7 @@ def mkrel(nodeid: str) -> str:
937
940
line += "[" .join (values )
938
941
return line
939
942
940
- # collect_fspath comes from testid which has a "/"-normalized path.
943
+ # fspath comes from testid which has a "/"-normalized path.
941
944
if fspath :
942
945
res = mkrel (nodeid )
943
946
if self .verbosity >= 2 and nodeid .split ("::" )[0 ] != fspath .replace (
0 commit comments