Skip to content
Closed
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
7 changes: 5 additions & 2 deletions src/pytest_cov/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
from . import engine


PYTEST_VERSION = tuple(map(int, pytest.__version__.split('.')[:3]))


class CoverageError(Exception):
"""Indicates that our coverage is too low"""

Expand Down Expand Up @@ -260,7 +263,7 @@ def pytest_runtestloop(self, session):
message = 'Failed to generate report: %s\n' % exc
session.config.pluginmanager.getplugin("terminalreporter").write(
'WARNING: %s\n' % message, red=True, bold=True)
if pytest.__version__ >= '3.8':
if PYTEST_VERSION >= (3, 8):
warnings.warn(pytest.PytestWarning(message))
else:
session.config.warn(code='COV-2', message=message)
Expand All @@ -274,7 +277,7 @@ def pytest_terminal_summary(self, terminalreporter):
if self._disabled:
message = 'Coverage disabled via --no-cov switch!'
terminalreporter.write('WARNING: %s\n' % message, red=True, bold=True)
if pytest.__version__ >= '3.8':
if PYTEST_VERSION >= (3, 8):
warnings.warn(pytest.PytestWarning(message))
else:
terminalreporter.config.warn(code='COV-1', message=message)
Expand Down