-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid truncation when truncating means longer output #10446
Avoid truncation when truncating means longer output #10446
Conversation
4faa5c0
to
25fbd3f
Compare
@nicoddemus anything I can do to make the review easier ? :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Pierre-Sassoulas, sorry for the delay and thanks for the ping.
LGTM, left a few small comments, please take a look. 👍
changelog/6267.feature.rst
Outdated
@@ -0,0 +1,2 @@ | |||
The full output of a test is no longer truncated if the truncation message would be longer than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this file would be better marked as improvement
in the changelog, so can you please rename it to 6267.improvement.rst
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in e7a48a2
src/_pytest/assertion/truncate.py
Outdated
# Add ellipsis to final line | ||
truncated_explanation[-1] = truncated_explanation[-1] + "..." | ||
# We reevaluate the need to truncate following removal of some lines | ||
if len("".join(input_lines)) > tolerable_max_chars: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you use truncated_explanation
here?
if len("".join(input_lines)) > tolerable_max_chars: | |
if len("".join(truncated_explanation)) > tolerable_max_chars: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If so, probably best to update the comment above:
# We reevaluate the need to truncate chars following removal of some lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch ! This led to further improvement in 4d2c40f
I can cleanup the history and rebase if you want. I'm not sure if the current fail from the CI is due to my changes, so maybe rebasing would help ?
|
The failure will be fixed in #10578, once we merge that don't worry that we can rebase this PR. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Pierre-Sassoulas!
LGTM, great work! I will leave this up for a few more days in case anybody else wants to review it.
@Pierre-Sassoulas |
Also fixes the dislayed line hidden message Closes pytest-dev#6267
b3fddc4
to
a5f6d75
Compare
Strange, "allow edit by maintainer" is checked. I rebased, I'm going to check the macos fail later today :) |
I triggered the job again, and now it passed, so it seems like it was a flaky error, so do not worry. |
The full output of a test is no longer truncated if the truncation message would be longer than
the hidden text. The line number shown has also been fixed.
I also used f-string for faster string formatting in a previous commit, I don't think this warrant another MR though.
Closes #6267