Skip to content

Commit f80178d

Browse files
committed
added tests for --cov-report=""
1 parent f24ec87 commit f80178d

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

cov-core/cov_core.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,13 @@ def sep(stream, s, txt):
7878

7979
def summary(self, stream):
8080
"""Produce coverage reports."""
81-
if self.cov_report == ['']:
82-
return
83-
8481
total = 0
8582

83+
if self.cov_report == ['']:
84+
with open(os.devnull, 'w') as null:
85+
total = self.cov.report(show_missing=True, ignore_errors=True, file=null)
86+
return total
87+
8688
# Output coverage section header.
8789
if len(self.node_descs) == 1:
8890
self.sep(stream, '-', 'coverage: %s' % ''.join(self.node_descs))

pytest-cov/pytest_cov.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def pytest_terminal_summary(self, terminalreporter):
155155
return
156156
if not (self.failed and self.options.no_cov_on_fail):
157157
total = self.cov_controller.summary(terminalreporter.writer)
158+
assert total is not None, 'Test coverage should never be `None`'
158159
cov_min = self.options.cov_min
159160
if cov_min is not None and total < cov_min:
160161
raise CoverageError(('Required test coverage of %d%% not '

pytest-cov/test_pytest_cov.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ def test_cov_min_no_report(testdir):
142142

143143
result = testdir.runpytest('-v',
144144
'--cov', '--cov-source=%s' % script.dirpath(),
145+
'--cov-report=',
145146
'--cov-min=50',
146147
script)
147148

0 commit comments

Comments
 (0)