Skip to content

Commit 3060625

Browse files
authored
Merge pull request #572 from pytest-dev/pytest6
Remove compat for pytest < 6
2 parents ba83984 + d153e0a commit 3060625

File tree

3 files changed

+12
-35
lines changed

3 files changed

+12
-35
lines changed

src/xdist/remote.py

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import time
1212

1313
import py
14-
import _pytest.hookspec
1514
import pytest
1615
from execnet.gateway_base import dumps, DumpError
1716

@@ -101,11 +100,8 @@ def pytest_collection_finish(self, session):
101100
def pytest_runtest_logstart(self, nodeid, location):
102101
self.sendevent("logstart", nodeid=nodeid, location=location)
103102

104-
# the pytest_runtest_logfinish hook was introduced in pytest 3.4
105-
if hasattr(_pytest.hookspec, "pytest_runtest_logfinish"):
106-
107-
def pytest_runtest_logfinish(self, nodeid, location):
108-
self.sendevent("logfinish", nodeid=nodeid, location=location)
103+
def pytest_runtest_logfinish(self, nodeid, location):
104+
self.sendevent("logfinish", nodeid=nodeid, location=location)
109105

110106
def pytest_runtest_logreport(self, report):
111107
data = self.config.hook.pytest_report_to_serializable(
@@ -125,29 +121,14 @@ def pytest_collectreport(self, report):
125121
)
126122
self.sendevent("collectreport", data=data)
127123

128-
# the pytest_warning_recorded hook was introduced in pytest 6.0
129-
if hasattr(_pytest.hookspec, "pytest_warning_recorded"):
130-
131-
def pytest_warning_recorded(self, warning_message, when, nodeid, location):
132-
self.sendevent(
133-
"warning_recorded",
134-
warning_message_data=serialize_warning_message(warning_message),
135-
when=when,
136-
nodeid=nodeid,
137-
location=location,
138-
)
139-
140-
# the pytest_warning_captured hook was introduced in pytest 3.8
141-
elif hasattr(_pytest.hookspec, "pytest_warning_captured"):
142-
143-
def pytest_warning_captured(self, warning_message, when, item):
144-
self.sendevent(
145-
"warning_captured",
146-
warning_message_data=serialize_warning_message(warning_message),
147-
when=when,
148-
# item cannot be serialized and will always be None when used with xdist
149-
item=None,
150-
)
124+
def pytest_warning_recorded(self, warning_message, when, nodeid, location):
125+
self.sendevent(
126+
"warning_recorded",
127+
warning_message_data=serialize_warning_message(warning_message),
128+
when=when,
129+
nodeid=nodeid,
130+
location=location,
131+
)
151132

152133

153134
def serialize_warning_message(warning_message):

src/xdist/workermanage.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,7 @@ def process_from_remote(self, eventcall): # noqa too complex
379379
except: # noqa
380380
from _pytest._code import ExceptionInfo
381381

382-
# ExceptionInfo API changed in pytest 4.1
383-
if hasattr(ExceptionInfo, "from_current"):
384-
excinfo = ExceptionInfo.from_current()
385-
else:
386-
excinfo = ExceptionInfo()
382+
excinfo = ExceptionInfo.from_current()
387383
print("!" * 20, excinfo)
388384
self.config.notify_exception(excinfo)
389385
self.shutdown()

testing/acceptance_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ def parse_tests_and_workers_from_output(lines):
13481348
r"""
13491349
\[(gw\d)\] # worker
13501350
\s*
1351-
(?:\[\s*\d+%\])? # progress indicator (pytest >=3.3)
1351+
(?:\[\s*\d+%\])? # progress indicator
13521352
\s(.*?) # status string ("PASSED")
13531353
\s(.*::.*) # nodeid
13541354
""",

0 commit comments

Comments
 (0)