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

Fix comparison against installed PyTest version #353

Closed
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
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