Skip to content

Fix comparison against installed PyTest version #354

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

Merged
merged 3 commits into from
Nov 2, 2019
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ Authors
* Albert Tugushev - https://github.com./atugushev
* Martín Gaitán - https://github.com./mgaitan
* Hugo van Kemenade - https://github.com./hugovk
* Michael Manganiello - https://github.com./adamantike
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

2.8.2 (unreleased)
------------------

* Fixed ``RemovedInPytest4Warning`` when using Pytest 3.10.
Contributed by Michael Manganiello in `#354 <https://github.com./pytest-dev/pytest-cov/pull/354>`_.

2.8.1 (2019-10-05)
------------------

Expand Down
6 changes: 4 additions & 2 deletions src/pytest_cov/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from . import embed
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 +262,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 +276,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