Skip to content

Commit

Permalink
Support pytest < 6.0 again
Browse files Browse the repository at this point in the history
Fixes #5
  • Loading branch information
christiansandberg committed Nov 5, 2020
1 parent e6fe750 commit 9794848
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pytest_reporter/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from itertools import chain

import pytest
import _pytest.hookspec


def pytest_addoption(parser):
Expand Down Expand Up @@ -165,8 +166,13 @@ def pytest_runtest_logfinish(self, nodeid):
self.context["tests"].append(testrun)
del self._active_tests[nodeid]

def pytest_warning_recorded(self, warning_message):
self.context["warnings"].append(warning_message)
# the pytest_warning_recorded hook was introduced in pytest 6.0
if hasattr(_pytest.hookspec, "pytest_warning_recorded"):
def pytest_warning_recorded(self, warning_message):
self.context["warnings"].append(warning_message)
else:
def pytest_warning_captured(self, warning_message):
self.context["warnings"].append(warning_message)

def pytest_sessionfinish(self, session):
self.context["ended"] = time.time()
Expand Down

0 comments on commit 9794848

Please sign in to comment.