Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/pytest_cov/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
from .compat import StringIO, workeroutput, workerinput


class _NullFile(object):
@staticmethod
def write(v):
pass


class CovController(object):
"""Base class for different plugin implementations."""

Expand Down Expand Up @@ -85,9 +91,7 @@ def summary(self, stream):
total = 0

if not self.cov_report:
with open(os.devnull, 'w') as null:
total = self.cov.report(show_missing=True, ignore_errors=True, file=null)
return total
return self.cov.report(show_missing=True, ignore_errors=True, file=_NullFile)

# Output coverage section header.
if len(self.node_descs) == 1:
Expand Down Expand Up @@ -115,7 +119,7 @@ def summary(self, stream):
self.cov.annotate(ignore_errors=True, directory=annotate_dir)
# We need to call Coverage.report here, just to get the total
# Coverage.annotate don't return any total and we need it for --cov-fail-under.
total = self.cov.report(ignore_errors=True, file=StringIO())
total = self.cov.report(ignore_errors=True, file=_NullFile)
if annotate_dir:
stream.write('Coverage annotated source written to dir %s\n' % annotate_dir)
else:
Expand Down