Skip to content

Commit

Permalink
--co disables --cov-fail-under
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Dec 11, 2021
1 parent 5182e59 commit 6925fcf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ Authors
* Brian Rutledge - https://github.com/bhrutledge
* Danilo Šegan - https://github.com/dsegan
* Michał Bielawski - https://github.com/D3X
* Zac Hatfield-Dodds - https://github.com/Zac-HD
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ Changelog
=========


3.1.0 (future)
-------------------

* `--cov-fail-under` no longer causes `pytest --collect-only` to fail
Contributed by Zac Hatfield-Dodds in
`#511 <https://github.com/pytest-dev/pytest-cov/pull/511>`_.


3.0.0 (2021-10-04)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion src/pytest_cov/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def pytest_runtestloop(self, session):
warnings.warn(CovReportWarning(message))
self.cov_total = 0
assert self.cov_total is not None, 'Test coverage should never be `None`'
if self._failed_cov_total():
if self._failed_cov_total() and not self.options.collectonly:
# make sure we get the EXIT_TESTSFAILED exit code
compat_session.testsfailed += 1

Expand Down
13 changes: 13 additions & 0 deletions tests/test_pytest_cov.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,19 @@ def test_cov_min_100(testdir):
])


def test_cov_min_100_passes_if_collectonly(testdir):
script = testdir.makepyfile(SCRIPT)

result = testdir.runpytest('-v',
'--cov=%s' % script.dirpath(),
'--cov-report=term-missing',
'--cov-fail-under=100',
'--collect-only',
script)

assert result.ret == 0


def test_cov_min_50(testdir):
script = testdir.makepyfile(SCRIPT)

Expand Down

0 comments on commit 6925fcf

Please sign in to comment.