Skip to content

Commit 8543247

Browse files
[perf] Use f-string instead of formatting for truncation message
1 parent 646a46e commit 8543247

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/_pytest/assertion/truncate.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ def _truncate_explanation(
6262
# Append useful message to explanation
6363
truncated_line_count = len(input_lines) - len(truncated_explanation)
6464
truncated_line_count += 1 # Account for the part-truncated final line
65-
msg = "...Full output truncated"
66-
if truncated_line_count == 1:
67-
msg += f" ({truncated_line_count} line hidden)"
68-
else:
69-
msg += f" ({truncated_line_count} lines hidden)"
70-
msg += f", {USAGE_MSG}"
71-
truncated_explanation.extend(["", str(msg)])
65+
truncated_explanation.extend(
66+
[
67+
"", # Line break
68+
f"...Full output truncated ({truncated_line_count} line"
69+
f"{'' if truncated_line_count == 1 else 's'} hidden), {USAGE_MSG}",
70+
]
71+
)
7272
return truncated_explanation
7373

7474

0 commit comments

Comments
 (0)