Skip to content

Commit

Permalink
[perf] Use f-string instead of formatting for truncation message
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Sassoulas committed Oct 29, 2022
1 parent 646a46e commit 8543247
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/_pytest/assertion/truncate.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ def _truncate_explanation(
# Append useful message to explanation
truncated_line_count = len(input_lines) - len(truncated_explanation)
truncated_line_count += 1 # Account for the part-truncated final line
msg = "...Full output truncated"
if truncated_line_count == 1:
msg += f" ({truncated_line_count} line hidden)"
else:
msg += f" ({truncated_line_count} lines hidden)"
msg += f", {USAGE_MSG}"
truncated_explanation.extend(["", str(msg)])
truncated_explanation.extend(
[
"", # Line break
f"...Full output truncated ({truncated_line_count} line"
f"{'' if truncated_line_count == 1 else 's'} hidden), {USAGE_MSG}",
]
)
return truncated_explanation


Expand Down

0 comments on commit 8543247

Please sign in to comment.