File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,16 +101,15 @@ def _truncate_explanation(
101101 # No truncation happened, so we do not need to add any explanations
102102 return truncated_explanation
103103
104- truncated_line_count = len (input_lines ) - len (truncated_explanation )
105104 if truncated_explanation [- 1 ]:
106105 # Add ellipsis and take into account part-truncated final line
107106 truncated_explanation [- 1 ] = truncated_explanation [- 1 ] + "..."
108- if truncated_char :
109- # It's possible that we did not remove any char from this line
110- truncated_line_count += 1
111107 else :
112108 # Add proper ellipsis when we were able to fit a full line exactly
113109 truncated_explanation [- 1 ] = "..."
110+ truncated_line_count = (
111+ len (input_lines ) - len (truncated_explanation ) + int (truncated_char )
112+ )
114113 return [
115114 * truncated_explanation ,
116115 "" ,
Original file line number Diff line number Diff line change @@ -1394,6 +1394,17 @@ def test_truncates_at_8_lines_when_there_is_one_line_to_remove(self) -> None:
13941394 assert result == expl
13951395 assert "truncated" not in result [- 1 ]
13961396
1397+ def test_truncates_full_line_because_of_max_chars (self ) -> None :
1398+ """A line is fully truncated because of the max_chars value."""
1399+ expl = ["a" * 10 , "b" * 71 ]
1400+ result = truncate ._truncate_explanation (expl , max_lines = 10 , max_chars = 10 )
1401+ assert result == [
1402+ "a" * 10 ,
1403+ "..." ,
1404+ "" ,
1405+ "...Full output truncated (1 line hidden), use '-vv' to show" ,
1406+ ]
1407+
13971408 def test_truncates_edgecase_when_truncation_message_makes_the_result_longer_for_chars (
13981409 self ,
13991410 ) -> None :
You can’t perform that action at this time.
0 commit comments