Merge pull request #390 from nicoddemus/pytest-logwarning

Prepare for the removal of pytest_logwarning in pytest 4.1
This commit is contained in:
Bruno Oliveira
2018-12-12 08:59:21 -02:00
committed by GitHub
3 changed files with 13 additions and 9 deletions

View File

@@ -1 +1 @@
Add support for pytest 4.1.
pytest 4.1 support: ``ExceptionInfo`` API changes.

1
changelog/390.bugfix.rst Normal file
View File

@@ -0,0 +1 @@
pytest 4.1 support: ``pytest_logwarning`` hook removed.

View File

@@ -115,14 +115,17 @@ class WorkerInteractor(object):
data = serialize_report(report)
self.sendevent("collectreport", data=data)
def pytest_logwarning(self, message, code, nodeid, fslocation):
self.sendevent(
"logwarning",
message=message,
code=code,
nodeid=nodeid,
fslocation=str(fslocation),
)
# the pytest_logwarning hook was removed in pytest 4.1
if hasattr(_pytest.hookspec, "pytest_logwarning"):
def pytest_logwarning(self, message, code, nodeid, fslocation):
self.sendevent(
"logwarning",
message=message,
code=code,
nodeid=nodeid,
fslocation=str(fslocation),
)
# the pytest_warning_captured hook was introduced in pytest 3.8
if hasattr(_pytest.hookspec, "pytest_warning_captured"):