-
-
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
Show "short test summary info" after tracebacks and warnings #3255
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.
i am under the impression this needlessly introduces a new hook, when hook ordering and moving the terminal plug-ins own summary into said hook is sufficient
tryfirst/trylast should match it nicely already
Good point, I was also under that impression but thought opening a PR first to invite comments. BUT if we follow this approach I think we will re-introduce #1305 no? |
@ionelmc what do you think? I'm under the impression that if we follow @RonnyPfannschmidt your code which initially detected this problem will keep working as expected, because your third party hook will be called first by default. |
@nicoddemus dunno which code or hook you're thinking about but I can say:
|
I thought the ordering problem was fixed? If it regressed and this PR fixes it again 👍 from me 😁 |
Ah, well pytest-benchmark is using pytest_terminal_summary, so I guess this PR is fine? I can give it a test if you want. |
The original problem was that self.summary_errors()
self.summary_failures()
self.summary_warnings() # < warning count captured and shown here
self.config.hook.pytest_terminal_summary(terminalreporter=self) # <- pytest-benchmark hook called at this point @RonnyPfannschmidt suggests that
self.config.hook.pytest_terminal_summary(terminalreporter=self)
def pytest_terminal_summary():
self.summary_errors()
self.summary_failures()
self.summary_warnings() I'm pretty sure this will work and not introduce a regression as |
a0fcb56
to
9e4c525
Compare
@RonnyPfannschmidt implemented your suggestion. 👍 |
9e4c525
to
4e405dd
Compare
_pytest/terminal.py
Outdated
@@ -480,16 +480,21 @@ def pytest_sessionfinish(self, exitstatus): | |||
EXIT_NOTESTSCOLLECTED) | |||
if exitstatus in summary_exit_codes: | |||
self.config.hook.pytest_terminal_summary(terminalreporter=self, | |||
config=self.config, |
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.
dito
_pytest/hookspec.py
Outdated
@@ -489,8 +489,16 @@ def pytest_report_teststatus(report): | |||
Stops at first non-None result, see :ref:`firstresult` """ | |||
|
|||
|
|||
def pytest_terminal_summary(terminalreporter, exitstatus): | |||
""" add additional section in terminal summary reporting. """ | |||
def pytest_terminal_summary(config, terminalreporter, exitstatus): |
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.
this is a breaking change, any caller of the hook would need to add the extra parameter
this needs to be addressed in pluggy first
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.
This hook is called only by terminal.py
, and we've added parameters to hooks in the past, it's not clear to me why this hook in particular cannot receive an extra argument at this point.
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.
in this particular hooks its probably less of an issue, however all hooks and the required arguments they take are currently part of the public api
for example pytest_deselected
is in dire need of a added reason
argument however its one of the hooks that are supposed to be called by 3rd parties, and they would simply break
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 see what you mean regarding pytest_deselected
, but AFAIK this is the only hook where we expect to be called by 3rd parties, all other hooks are called by pytest itself.
So IMHO your concern is valid but not for most hooks.
Having said all that, if you really want I can remove the parameter, it was not really required by the hook implementations I touched.
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.
im leaning torwards removing it, but as you said, its unlikely to be invoked by 3rd parties as of now
we ought to create a mechanism trough which 3rd parties defer to hooks later on
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.
No worries, removed it. 👍
thanks ^^ |
Currently when using
-ra
the "short test summary info" is shown before the full list of tracebacks and errors:When you have a large test suite and a lot of tests fail, the short summary test info easily gets lost amidst the huge number of lines printed by all the tracebacks.
I tracked this to a change introduced in #1305 (by yours truly) which was meant to fix the warnings count, but have this unfortunate side effect.
With the change the output now becomes:
In order to avoid breakages and further surprises I thought better to create a new hook because changing the place where
pytest_terminal_summary
is called yet again would be worse I think.