-
-
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
code: handle repr'ing empty tracebacks gracefully #10907
Conversation
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.
Looks great, thanks!
By "empty traceback" I mean a traceback all of whose entries have been filtered/cut/pruned out. Currently, if an empty traceback needs to be repr'ed, the last entry before the filtering is used instead (added in accd962). Showing a hidden frame is not so good IMO. This commit does the following instead: 1. Shows details of the exception. 2. Shows a message about how the full trace can be seen. Example: ``` _____________ test _____________ E ZeroDivisionError: division by zero All traceback entries are hidden. Pass `--full-trace` to see hidden and internal frames. ``` Also handles `--tb=native`, though there the `--full-trace` bit is not shown. This commit contains some pieces from 431ec6d (which has been reverted). Helps towards fixing issue # 1904. Co-authored-by: Felix Hofstätter <[email protected]>
e29a6e0
to
e3b1799
Compare
@RonnyPfannschmidt here you proposed replacing pruning with collapsing, i.e. showing "10 frames hidden by pytest" or similar. This might be good, but I think most of the time it would be redundant, people don't really care about the hidden frames. For the case where all frames are hidden, just showing a message seems good enough to me. It's not something that is really normal. I just remembered that I should test pytest-bdd with this change, as that's the package which triggered this situation in the first place. Will do it later. |
A key bit for this would be to enable expansions in better ux |
Aka pytest-html or a potential pytest-textual allowing to expand the collapsed frames |
Yea, thinking about it a bit more I definitely agree that it would be better, instead of physically cutting out the hidden frames from the traceback, to instead mark them as hidden, and leave it to the "UI" code to not show them. Will be a good improvement for the future. |
doc: add missing changelog for #10907
By "empty traceback" I mean a traceback all of whose entries have been filtered/cut/pruned out.
Currently, if an empty traceback needs to be repr'ed, the last entry before the filtering is used instead (added in
accd962).
Showing a hidden frame is not so good IMO. This commit does the following instead:
Example:
Also handles
--tb=native
, though there the--full-trace
bit is not shown.This commit contains some pieces from
431ec6d (which has been reverted).
Helps towards fixing issue #1904.