Skip to content

Commit a30124e

Browse files
committed
Prepare for the removal of pytest_logwarning in pytest 4.1
1 parent c5d8635 commit a30124e

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

xdist/remote.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,17 @@ def pytest_collectreport(self, report):
115115
data = serialize_report(report)
116116
self.sendevent("collectreport", data=data)
117117

118-
def pytest_logwarning(self, message, code, nodeid, fslocation):
119-
self.sendevent(
120-
"logwarning",
121-
message=message,
122-
code=code,
123-
nodeid=nodeid,
124-
fslocation=str(fslocation),
125-
)
118+
# the pytest_logwarning hook was removed in pytest 4.1
119+
if hasattr(_pytest.hookspec, "pytest_logwarning"):
120+
121+
def pytest_logwarning(self, message, code, nodeid, fslocation):
122+
self.sendevent(
123+
"logwarning",
124+
message=message,
125+
code=code,
126+
nodeid=nodeid,
127+
fslocation=str(fslocation),
128+
)
126129

127130
# the pytest_warning_captured hook was introduced in pytest 3.8
128131
if hasattr(_pytest.hookspec, "pytest_warning_captured"):

0 commit comments

Comments
 (0)