Skip to content
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

--report-type='' implies no --cov-fail-under #199

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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