File 0001-Revert-Remove-compat-for-pytest-6.patch of Package python-pytest-xdist
From 9e81d88e5e9ac12cebc9848466560489b3064982 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mark=C3=A9ta=20Cal=C3=A1bkov=C3=A1?=
<meggy.calabkova@gmail.com>
Date: Mon, 31 Aug 2020 15:50:54 +0200
Subject: [PATCH] Revert "Remove compat for pytest < 6"
This reverts commit d153e0a4c4b764c821da9907ba3d2cac31bc3884.
Updated on 2022-01-15
---
src/xdist/remote.py | 44 ++++++++++++++++++++++++++++++++------------
src/xdist/workermanage.py | 6 +++++-
testing/acceptance_test.py | 2 +-
3 files changed, 38 insertions(+), 14 deletions(-)
--- a/src/xdist/remote.py 2022-01-15 19:11:37.443540560 +0100
+++ b/src/xdist/remote.py 2022-01-15 19:18:58.911532654 +0100
@@ -11,6 +11,7 @@ import os
import time
import py
+import _pytest.hookspec
import pytest
from execnet.gateway_base import dumps, DumpError
@@ -147,9 +148,12 @@ class WorkerInteractor:
def pytest_runtest_logstart(self, nodeid, location):
self.sendevent("logstart", nodeid=nodeid, location=location)
- @pytest.hookimpl
- def pytest_runtest_logfinish(self, nodeid, location):
- self.sendevent("logfinish", nodeid=nodeid, location=location)
+ # the pytest_runtest_logfinish hook was introduced in pytest 3.4
+ if hasattr(_pytest.hookspec, "pytest_runtest_logfinish"):
+
+ @pytest.hookimpl
+ def pytest_runtest_logfinish(self, nodeid, location):
+ self.sendevent("logfinish", nodeid=nodeid, location=location)
@pytest.hookimpl
def pytest_runtest_logreport(self, report):
@@ -171,15 +175,31 @@ class WorkerInteractor:
)
self.sendevent("collectreport", data=data)
- @pytest.hookimpl
- def pytest_warning_recorded(self, warning_message, when, nodeid, location):
- self.sendevent(
- "warning_recorded",
- warning_message_data=serialize_warning_message(warning_message),
- when=when,
- nodeid=nodeid,
- location=location,
- )
+ # the pytest_warning_recorded hook was introduced in pytest 6.0
+ if hasattr(_pytest.hookspec, "pytest_warning_recorded"):
+
+ @pytest.hookimpl
+ def pytest_warning_recorded(self, warning_message, when, nodeid, location):
+ self.sendevent(
+ "warning_recorded",
+ warning_message_data=serialize_warning_message(warning_message),
+ when=when,
+ nodeid=nodeid,
+ location=location,
+ )
+
+ # the pytest_warning_captured hook was introduced in pytest 3.8
+ elif hasattr(_pytest.hookspec, "pytest_warning_captured"):
+
+ @pytest.hookimpl
+ def pytest_warning_captured(self, warning_message, when, item):
+ self.sendevent(
+ "warning_captured",
+ warning_message_data=serialize_warning_message(warning_message),
+ when=when,
+ # item cannot be serialized and will always be None when used with xdist
+ item=None,
+ )
def serialize_warning_message(warning_message):
--- a/src/xdist/workermanage.py 2022-01-15 19:11:37.443540560 +0100
+++ b/src/xdist/workermanage.py 2022-01-15 19:11:59.967540157 +0100
@@ -386,7 +386,11 @@ class WorkerController:
except: # noqa
from _pytest._code import ExceptionInfo
- excinfo = ExceptionInfo.from_current()
+ # ExceptionInfo API changed in pytest 4.1
+ if hasattr(ExceptionInfo, "from_current"):
+ excinfo = ExceptionInfo.from_current()
+ else:
+ excinfo = ExceptionInfo()
print("!" * 20, excinfo)
self.config.notify_exception(excinfo)
self.shutdown()
--- a/testing/acceptance_test.py 2022-01-15 19:11:37.463540560 +0100
+++ b/testing/acceptance_test.py 2022-01-15 19:11:59.967540157 +0100
@@ -1530,7 +1530,7 @@ def parse_tests_and_workers_from_output(
r"""
\[(gw\d)\] # worker
\s*
- (?:\[\s*\d+%\])? # progress indicator
+ (?:\[\s*\d+%\])? # progress indicator (pytest >=3.3)
\s(.*?) # status string ("PASSED")
\s(.*::.*) # nodeid
""",