@@ -629,12 +629,12 @@ def _print_failure_details(self, report: TestReport) -> None:
629629 lines = longrepr_str .split ("\n " )
630630
631631 # Extract the main error message and location
632- # Skip verbose diff output, "Differing items:", "use `-vv`" messages, etc.
633632 error_message = None
634633 error_type = None
635634 file_location = None
636635 file_path = None
637636 line_number = None
637+ introspection_lines : list [str ] = []
638638
639639 import re
640640
@@ -657,32 +657,37 @@ def _print_failure_details(self, report: TestReport) -> None:
657657 except (ValueError , IndexError ):
658658 pass
659659
660- # Get the first meaningful error message (E line with error info)
661- if error_message is None and stripped .startswith ("E " ):
660+ if stripped .startswith ("E " ):
662661 error_content = stripped [2 :].strip ()
663662
664- # Match "SomeName: message" where SomeName has no spaces (exception class)
665- if ": " in error_content :
666- before_colon = error_content .split (": " , 1 )[0 ]
667- if " " not in before_colon and before_colon :
668- error_message = error_content .split (": " , 1 )[1 ]
669- # Extract error type from the class name (last component)
670- error_type = before_colon .split ("." )[- 1 ]
671- # Skip verbose assertion rewrites with diffs
672- elif error_content .startswith ("assert " ) and not ('{' in error_content and '...' in error_content ):
673- error_message = error_content
663+ # Skip pytest hints about verbosity
664+ if "use -v" in error_content .lower ():
665+ continue
666+
667+ if error_message is None :
668+ # Match "SomeName: message" where SomeName has no spaces (exception class)
669+ if ": " in error_content :
670+ before_colon = error_content .split (": " , 1 )[0 ]
671+ if " " not in before_colon and before_colon :
672+ error_message = error_content .split (": " , 1 )[1 ]
673+ # Extract error type from the class name (last component)
674+ error_type = before_colon .split ("." )[- 1 ]
675+
676+ if error_message is None and error_content .startswith ("assert " ):
677+ error_message = error_content
678+ elif error_content :
679+ # Subsequent E lines are assertion introspection details
680+ introspection_lines .append (error_content )
674681
675682 # If we still don't have an error message, create one from error type
676683 if error_message is None and error_type :
677684 error_message = f"{ error_type } occurred."
678685
679686 # Display the error with elegant formatting
680687 if error_message :
681- # Clean up assertion messages with verbose comparisons
682- if "assert" in error_message .lower () and "==" in error_message :
683- error_message = "Failed asserting that values are equal."
684-
685688 self .write_line (f" { error_message } " , red = True )
689+ for intro_line in introspection_lines :
690+ self .write_line (f" { intro_line } " )
686691
687692 # Show file location if available
688693 if file_location :
0 commit comments