Skip to content

perf: only call summary when the report will be used #589

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

Merged
merged 2 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ Authors
* Colin O'Dell - https://github.com./colinodell
* Ronny Pfannschmidt - https://github.com./RonnyPfannschmidt
* Christian Fetzer - https://github.com./fetzerch
* Jonathan Stewmon = https://github.com./jstewmon
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ Changelog
=========


4.0.1 (2023-03-27)
------------------

* Skip generating the in-memory coverage report when it will not be used. For example,
when ``--cov-report=''`` is used without ``--cov-fail-under``.


4.0.0 (2022-09-28)
------------------

Expand Down
3 changes: 2 additions & 1 deletion src/pytest_cov/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ def pytest_testnodedown(self, node, error):
self.cov_controller.testnodedown(node, error)

def _should_report(self):
return not (self.failed and self.options.no_cov_on_fail)
needed = self.options.cov_report or self.options.cov_fail_under
return needed and not (self.failed and self.options.no_cov_on_fail)

def _failed_cov_total(self):
cov_fail_under = self.options.cov_fail_under
Expand Down