3535from _pytest import timing
3636from _pytest ._code import ExceptionInfo
3737from _pytest ._code .code import ExceptionRepr
38+ from _pytest ._io import TerminalWriter
3839from _pytest ._io .wcwidth import wcswidth
3940from _pytest .compat import final
4041from _pytest .config import _PluggyPlugin
@@ -1074,58 +1075,71 @@ def short_test_summary(self) -> None:
10741075 if not self .reportchars :
10751076 return
10761077
1077- def show_simple (stat , lines : List [str ]) -> None :
1078+ def show_simple (lines : List [str ], * , stat : str ) -> None :
10781079 failed = self .stats .get (stat , [])
10791080 if not failed :
10801081 return
1081- termwidth = self ._tw .fullwidth
10821082 config = self .config
10831083 for rep in failed :
1084- line = _get_line_with_reprcrash_message (config , rep , termwidth )
1084+ color = _color_for_type .get (stat , _color_for_type_default )
1085+ line = _get_line_with_reprcrash_message (
1086+ config , rep , self ._tw , {color : True }
1087+ )
10851088 lines .append (line )
10861089
10871090 def show_xfailed (lines : List [str ]) -> None :
10881091 xfailed = self .stats .get ("xfailed" , [])
10891092 for rep in xfailed :
10901093 verbose_word = rep ._get_verbose_word (self .config )
1091- pos = _get_pos (self .config , rep )
1092- lines .append (f"{ verbose_word } { pos } " )
1094+ markup_word = self ._tw .markup (
1095+ verbose_word , ** {_color_for_type ["warnings" ]: True }
1096+ )
1097+ nodeid = _get_node_id_with_markup (self ._tw , self .config , rep )
1098+ line = f"{ markup_word } { nodeid } "
10931099 reason = rep .wasxfail
10941100 if reason :
1095- lines .append (" " + str (reason ))
1101+ line += " - " + str (reason )
1102+
1103+ lines .append (line )
10961104
10971105 def show_xpassed (lines : List [str ]) -> None :
10981106 xpassed = self .stats .get ("xpassed" , [])
10991107 for rep in xpassed :
11001108 verbose_word = rep ._get_verbose_word (self .config )
1101- pos = _get_pos (self .config , rep )
1109+ markup_word = self ._tw .markup (
1110+ verbose_word , ** {_color_for_type ["warnings" ]: True }
1111+ )
1112+ nodeid = _get_node_id_with_markup (self ._tw , self .config , rep )
11021113 reason = rep .wasxfail
1103- lines .append (f"{ verbose_word } { pos } { reason } " )
1114+ lines .append (f"{ markup_word } { nodeid } { reason } " )
11041115
11051116 def show_skipped (lines : List [str ]) -> None :
11061117 skipped : List [CollectReport ] = self .stats .get ("skipped" , [])
11071118 fskips = _folded_skips (self .startpath , skipped ) if skipped else []
11081119 if not fskips :
11091120 return
11101121 verbose_word = skipped [0 ]._get_verbose_word (self .config )
1122+ markup_word = self ._tw .markup (
1123+ verbose_word , ** {_color_for_type ["warnings" ]: True }
1124+ )
1125+ prefix = "Skipped: "
11111126 for num , fspath , lineno , reason in fskips :
1112- if reason .startswith ("Skipped: " ):
1113- reason = reason [9 :]
1127+ if reason .startswith (prefix ):
1128+ reason = reason [len ( prefix ) :]
11141129 if lineno is not None :
11151130 lines .append (
1116- "%s [%d] %s:%d: %s"
1117- % (verbose_word , num , fspath , lineno , reason )
1131+ "%s [%d] %s:%d: %s" % (markup_word , num , fspath , lineno , reason )
11181132 )
11191133 else :
1120- lines .append ("%s [%d] %s: %s" % (verbose_word , num , fspath , reason ))
1134+ lines .append ("%s [%d] %s: %s" % (markup_word , num , fspath , reason ))
11211135
11221136 REPORTCHAR_ACTIONS : Mapping [str , Callable [[List [str ]], None ]] = {
11231137 "x" : show_xfailed ,
11241138 "X" : show_xpassed ,
1125- "f" : partial (show_simple , "failed" ),
1139+ "f" : partial (show_simple , stat = "failed" ),
11261140 "s" : show_skipped ,
1127- "p" : partial (show_simple , "passed" ),
1128- "E" : partial (show_simple , "error" ),
1141+ "p" : partial (show_simple , stat = "passed" ),
1142+ "E" : partial (show_simple , stat = "error" ),
11291143 }
11301144
11311145 lines : List [str ] = []
@@ -1135,7 +1149,7 @@ def show_skipped(lines: List[str]) -> None:
11351149 action (lines )
11361150
11371151 if lines :
1138- self .write_sep ("=" , "short test summary info" )
1152+ self .write_sep ("=" , "short test summary info" , cyan = True , bold = True )
11391153 for line in lines :
11401154 self .write_line (line )
11411155
@@ -1249,9 +1263,14 @@ def _build_collect_only_summary_stats_line(
12491263 return parts , main_color
12501264
12511265
1252- def _get_pos ( config : Config , rep : BaseReport ):
1266+ def _get_node_id_with_markup ( tw : TerminalWriter , config : Config , rep : BaseReport ):
12531267 nodeid = config .cwd_relative_nodeid (rep .nodeid )
1254- return nodeid
1268+ path , * parts = nodeid .split ("::" )
1269+ if parts :
1270+ parts_markup = tw .markup ("::" .join (parts ), bold = True )
1271+ return path + "::" + parts_markup
1272+ else :
1273+ return path
12551274
12561275
12571276def _format_trimmed (format : str , msg : str , available_width : int ) -> Optional [str ]:
@@ -1280,13 +1299,14 @@ def _format_trimmed(format: str, msg: str, available_width: int) -> Optional[str
12801299
12811300
12821301def _get_line_with_reprcrash_message (
1283- config : Config , rep : BaseReport , termwidth : int
1302+ config : Config , rep : BaseReport , tw : TerminalWriter , word_markup : Dict [ str , bool ]
12841303) -> str :
12851304 """Get summary line for a report, trying to add reprcrash message."""
12861305 verbose_word = rep ._get_verbose_word (config )
1287- pos = _get_pos (config , rep )
1306+ word = tw .markup (verbose_word , ** word_markup )
1307+ node = _get_node_id_with_markup (tw , config , rep )
12881308
1289- line = f"{ verbose_word } { pos } "
1309+ line = f"{ word } { node } "
12901310 line_width = wcswidth (line )
12911311
12921312 try :
@@ -1295,7 +1315,7 @@ def _get_line_with_reprcrash_message(
12951315 except AttributeError :
12961316 pass
12971317 else :
1298- available_width = termwidth - line_width
1318+ available_width = tw . fullwidth - line_width
12991319 msg = _format_trimmed (" - {}" , msg , available_width )
13001320 if msg is not None :
13011321 line += msg
0 commit comments