Skip to content

Commit

Permalink
Merge pull request #230 from MarSoft/patch-1
Browse files Browse the repository at this point in the history
Don't use deprecated config.warn
  • Loading branch information
blueyed authored Nov 15, 2018
2 parents 7205428 + 325ab2e commit 22acb3e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pytest_cov/plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Coverage plugin for pytest."""
import os
import warnings

import pytest
import argparse
Expand Down Expand Up @@ -234,7 +235,10 @@ 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)
session.config.warn(code='COV-2', message=message)
if pytest.__version__ >= '3.8':
warnings.warn(pytest.PytestWarning(message))
else:
session.config.warn(code='COV-2', message=message)
self.cov_total = 0
assert self.cov_total is not None, 'Test coverage should never be `None`'
if self._failed_cov_total():
Expand All @@ -245,7 +249,10 @@ 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)
terminalreporter.config.warn(code='COV-1', message=message)
if pytest.__version__ >= '3.8':
warnings.warn(pytest.PytestWarning(message))
else:
terminalreporter.config.warn(code='COV-1', message=message)
return
if self.cov_controller is None:
return
Expand Down

0 comments on commit 22acb3e

Please sign in to comment.