-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Improve/revisit CallInfo.__repr__ #6007
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
Conversation
5159b3a
to
3eb2d50
Compare
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.
lovely just so much more nice
src/_pytest/runner.py
Outdated
) | ||
if self.excinfo is None: | ||
return "<CallInfo when={!r} result: {!r}>".format(self.when, self._result) | ||
return "<CallInfo when={!r} exc: {!r}>".format(self.when, self.excinfo.value) |
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.
based on the final traceback, how about using "<CallInfo when={!r} {!r}: {}>".format(self.when, self.excinfo.type, self.excinfo.value)
soit would spell <CallInfo when='123' ZeroDivisionError: division by zero>
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.
Should use str(self.excinfo.type.__name__)
then likely, and using str(self.excinfo.value)
has the original issue, that it would contain literal "\n".
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 just using repr(self.excinfo)
is good - it is always good to use reprs in __repr__
after all.
We could drop the "exc: " prefix though? (Done.)
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.
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.
Having repr(self.excinfo)
there might be also good/better, since it would include tblen
:
<ExceptionInfo AssertionError('tearDown\nassert 0') tblen=1>
, but makes it a bit longer.
Having it as excinfo=<ExceptionInfo AssertionError('tearDown\nassert 0') tblen=1>
therein would clearly indicate that it is a property, too.
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 like it
wrt the trace-back, i was starting at the trace back in the pr about that character difference in the zerodivisionerror
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 like it
Which one? The whole repr of excinfo with excinfo=
prefix?
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.
yup
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.
Amended.
3eb2d50
to
5036b3f
Compare
5036b3f
to
15f9568
Compare
Hmmm this definitely should include a changelog entry ( |
@nicoddemus |
Well it does change expected output... from someone who thinks any form of outward change to be possibly breaking, I'm suprised yout don't think this deserves a changelog entry. |
It's a minor internal improvement - I do not expect somebody to rely on parsing the |
Well, I still think it does not cost us much to write a single file with a single line externing that change to our users. :) |
What's the benefit? |
Well external changes, as small as they may be, might still break existing test suites and plugins. When that happens, it shows care from the maintainers if at least it is mentioned in the CHANGELOG. |
Agreed.
What is "careful" about being able to read in the changelog then something along "Improved Apart from that there's always git-log if you want to revisit all changes. I am not reading changelogs myself mostly, so extra verbosity does not hurt me (except for having to write it twice (git log and changelog), and having to run CI for it twice usually - mainly because we're not squash-merging, and a lot of these things have no issue/PR number when submitting them etc). For me it really adds extra friction/work, and I think it is better to fix minor issues like this, and not just skip them because you have to add noise / extra work for "documenting" them. |
As a plugin writer, I like to know when things that might break my test suite are properly mentioned in the CHANGELOG. Not because I will preemtively act on them, but when I get a breakage I can consult the CHANGELOG and pinpoint the cause without having to spend sometime debugging and wondering if it is my code or environment. I had this case recently in pytest-mock, when we changed the output of 1 extra items to 1 extra item, which broke a few tests. Of course I knew about the change before hand, but a normal user would very likely not know about it and might waste time investigating further. When we realize that this might happen with internal plugins in private companies which are part of very large code bases, then it makes even more sense to me.
I don't have any data to back me up, but I'm sure most users at least glance at the CHANGELOG when they see the release announcement.
Well I'm sorry if you feel this way, but I'm still convinced having a rich CHANGELOG demonstrates care by the maintainers and respect for the users. Feel free to start a vote/poll on the mailing list to change this policy, but I can add my 👎 in advance to that. And actually it boggles my mind that adding a single file to a commit where you often spent a few hours or minutes is such a friction to you. I usually just add them as part of the first commit. |
It shouldn't have literal newlines in it.