From a30124e858322d27b31941c6ce97c8c339f21e0d Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 11 Dec 2018 18:46:30 -0200 Subject: [PATCH] Prepare for the removal of pytest_logwarning in pytest 4.1 --- xdist/remote.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/xdist/remote.py b/xdist/remote.py index a0afa49..615a88c 100644 --- a/xdist/remote.py +++ b/xdist/remote.py @@ -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"):