Skip to content

Commit

Permalink
--report-type='' implies no --cov-fail-under
Browse files Browse the repository at this point in the history
  • Loading branch information
terencehonles committed Apr 14, 2018
1 parent 861955b commit 4411c8e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ Authors
* Zoltan Kozma - https://github.com/kozmaz87
* Francis Niu - https://flniu.github.io
* Jannis Leidel - https://github.com/jezdez
* Terence Honles - https://github.com/terencehonles
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Changelog
=========

2.5.2 (2018-04-14)
------------------

* Specifying ``--cov-report=`` will not output any report information and
will not check minimum coverage which may be specified with
``--cov-fail-under=MIN`` or through the config. This change is to allow
using ``--cov-append`` in future runs without reporting failure too early.


2.5.1 (2017-05-11)
------------------

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 @@ -206,7 +206,8 @@ def pytest_testnodedown(self, node, error):
pytest_testnodedown.optionalhook = True

def _should_report(self):
return not (self.failed and self.options.no_cov_on_fail)
return (self.options.cov_report
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
20 changes: 16 additions & 4 deletions tests/test_pytest_cov.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,20 @@ def test_cov_min_100(testdir):
])


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

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

assert result.ret != 0
assert ('FAIL Required test coverage of 100% not reached.'
not in result.stdout.str())


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

Expand All @@ -324,7 +338,7 @@ def test_cov_min_50(testdir):
])


def test_cov_min_no_report(testdir):
def test_cov_min_50_no_report(testdir):
script = testdir.makepyfile(SCRIPT)

result = testdir.runpytest('-v',
Expand All @@ -334,9 +348,7 @@ def test_cov_min_no_report(testdir):
script)

assert result.ret == 0
result.stdout.fnmatch_lines([
'Required test coverage of 50% reached. Total coverage: *%'
])
assert 'Required test coverage of 50% reached.' not in result.stdout.str()


def test_central_nonspecific(testdir, prop):
Expand Down

0 comments on commit 4411c8e

Please sign in to comment.