From 4e4e525aba39dcf6bbac341129b9e02e0b775088 Mon Sep 17 00:00:00 2001 From: "Terence D. Honles" Date: Sat, 14 Apr 2018 13:36:52 -0700 Subject: [PATCH] --report-type='' implies no --cov-fail-under --- AUTHORS.rst | 1 + CHANGELOG.rst | 9 +++++++++ src/pytest_cov/plugin.py | 3 ++- tests/test_pytest_cov.py | 20 ++++++++++++++++---- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index 47c405f9..62fc5ccd 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -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 diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 62f77e88..4a226345 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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) ------------------ diff --git a/src/pytest_cov/plugin.py b/src/pytest_cov/plugin.py index 46321d8a..4e769ecc 100644 --- a/src/pytest_cov/plugin.py +++ b/src/pytest_cov/plugin.py @@ -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 diff --git a/tests/test_pytest_cov.py b/tests/test_pytest_cov.py index 7f5cb627..359ed8ed 100644 --- a/tests/test_pytest_cov.py +++ b/tests/test_pytest_cov.py @@ -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) @@ -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', @@ -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):