Accepting request 1039058 from devel:languages:python:pytest

- Remove python_module macro definition
- Use autosetup instead of setup + autopatch
- Remove reintroduce-slave-terminology.patch
- Remove 0001-Revert-Remove-compat-for-pytest-6.patch
- Update to 3.0.2:
  # Bug Fixes
  * #813: Cancel shutdown when a crashed worker is restarted.
  # Deprecations
  * #825: The --rsyncdir command line argument and rsyncdirs config variable
    are deprecated.
  * The rsync feature will be removed in pytest-xdist 4.0.
  * #826: The --looponfail command line argument and looponfailroots config
    variable are deprecated.
  * The loop-on-fail feature will be removed in pytest-xdist 4.0.
  # Improved Documentation
  * #791: Document the pytest_xdist_auto_num_workers hook.
  * #796: Added known limitations section to documentation.
  * #829: Document the -n logical option.
  # Features
  * #792: The environment variable PYTEST_XDIST_AUTO_NUM_WORKERS can now be
    used to specify the default for -n auto and -n logical.
  * #812: Partially restore old initial batch distribution algorithm in
    LoadScheduling.
  * pytest orders tests for optimal sequential execution - i. e. avoiding
    unnecessary setup and teardown of fixtures. So executing tests in
    consecutive chunks is important for optimal performance.
  * In v1.14, initial test distribution in LoadScheduling was changed to
    round-robin, optimized for the corner case, when the number of tests is
    less than 2 * number of nodes. At the same time, it became worse for all
    other cases.
  * For example: if some tests use some "heavy" fixture, and these tests fit
    into the initial batch, with round-robin distribution the fixture will be
    created min(n_tests, n_workers) times, no matter how many other tests there
    are.
  * With the old algorithm (before v1.14), if there are enough tests not using
    the fixture, the fixture was created only once.
  * So restore the old behavior for typical cases where the number of tests is
    much greater than the number of workers (or, strictly speaking, when there
    are at least 2 tests for every node).
  # Removals
  * #468: The --boxed command-line option has been removed. If you still need
    this functionality, install pytest-forked separately.
  # Trivial Changes
  * #468: The py dependency has been dropped.
  * #822: Replace internal usage of py.log with a custom solution (but with the
    same interface).
  * #823: Remove usage of py._pydir as an rsync candidate.
  * #824: Replace internal usages of py.path.local by pathlib.Path.

OBS-URL: https://build.opensuse.org/request/show/1039058
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pytest-xdist?expand=0&rev=19
This commit is contained in:
Dominique Leuenberger 2023-01-06 16:04:27 +00:00 committed by Git OBS Bridge
commit a106c069c0
6 changed files with 73 additions and 252 deletions

View File

@ -1,108 +0,0 @@
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
""",

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4580deca3ff04ddb2ac53eba39d76cb5dd5edeac050cb6fbc768b0dd712b4edf
size 72455

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:688da9b814370e891ba5de650c9327d1a9d861721a524eb917e620eec3e90291
size 69590

View File

@ -1,3 +1,61 @@
-------------------------------------------------------------------
Wed Nov 30 08:01:07 UTC 2022 - Daniel Garcia <daniel.garcia@suse.com>
- Remove python_module macro definition
- Use autosetup instead of setup + autopatch
- Remove reintroduce-slave-terminology.patch
- Remove 0001-Revert-Remove-compat-for-pytest-6.patch
- Update to 3.0.2:
# Bug Fixes
* #813: Cancel shutdown when a crashed worker is restarted.
# Deprecations
* #825: The --rsyncdir command line argument and rsyncdirs config variable
are deprecated.
* The rsync feature will be removed in pytest-xdist 4.0.
* #826: The --looponfail command line argument and looponfailroots config
variable are deprecated.
* The loop-on-fail feature will be removed in pytest-xdist 4.0.
# Improved Documentation
* #791: Document the pytest_xdist_auto_num_workers hook.
* #796: Added known limitations section to documentation.
* #829: Document the -n logical option.
# Features
* #792: The environment variable PYTEST_XDIST_AUTO_NUM_WORKERS can now be
used to specify the default for -n auto and -n logical.
* #812: Partially restore old initial batch distribution algorithm in
LoadScheduling.
* pytest orders tests for optimal sequential execution - i. e. avoiding
unnecessary setup and teardown of fixtures. So executing tests in
consecutive chunks is important for optimal performance.
* In v1.14, initial test distribution in LoadScheduling was changed to
round-robin, optimized for the corner case, when the number of tests is
less than 2 * number of nodes. At the same time, it became worse for all
other cases.
* For example: if some tests use some "heavy" fixture, and these tests fit
into the initial batch, with round-robin distribution the fixture will be
created min(n_tests, n_workers) times, no matter how many other tests there
are.
* With the old algorithm (before v1.14), if there are enough tests not using
the fixture, the fixture was created only once.
* So restore the old behavior for typical cases where the number of tests is
much greater than the number of workers (or, strictly speaking, when there
are at least 2 tests for every node).
# Removals
* #468: The --boxed command-line option has been removed. If you still need
this functionality, install pytest-forked separately.
# Trivial Changes
* #468: The py dependency has been dropped.
* #822: Replace internal usage of py.log with a custom solution (but with the
same interface).
* #823: Remove usage of py._pydir as an rsync candidate.
* #824: Replace internal usages of py.path.local by pathlib.Path.
-------------------------------------------------------------------
Sat Jan 15 18:31:01 UTC 2022 - Matthias Fehring <buschmann23@opensuse.org>

View File

@ -16,32 +16,26 @@
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
Name: python-pytest-xdist
Version: 2.5.0
Version: 3.0.2
Release: 0
Summary: Distributed testing and loop-on-failing for py.test
License: MIT
URL: https://github.com/pytest-dev/pytest-xdist
Source0: https://files.pythonhosted.org/packages/source/p/pytest-xdist/pytest-xdist-%{version}.tar.gz
# This is actually revert of something upstream wanted to do a long time ago, but was waiting for the rest of pytest to sync with them.
# It is only a terminology change, but one that has personal meaning for many people. On the other hand, it was breaking compatibility with pytest < 6.
# In my opinion it would be inadequate to send this patch upstream.
Patch0: reintroduce-slave-terminology.patch
# minor compatibility revert
Patch1: 0001-Revert-Remove-compat-for-pytest-6.patch
BuildRequires: %{python_module execnet >= 1.1}
BuildRequires: %{python_module filelock}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module psutil >= 3.0.0}
BuildRequires: %{python_module pytest >= 4.4.0}
BuildRequires: %{python_module pytest-forked}
BuildRequires: %{python_module setuptools_scm >= 6.0}
BuildRequires: %{python_module pytest >= 6.2.0}
BuildRequires: %{python_module setuptools_scm >= 6.2.3}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-execnet >= 1.1
Requires: python-pytest >= 4.4.0
Requires: python-pytest-forked
Requires: python-pytest >= 6.2.0
Suggests: python-psutil >= 3.0.0
BuildArch: noarch
%python_subpackages
@ -71,25 +65,23 @@ are reported back and displayed to your local terminal.
You may specify different Python versions and interpreters.
%prep
%setup -q -n pytest-xdist-%{version}
%autopatch -p1
%autosetup -p1 -n pytest-xdist-%{version}
sed -i 's/\r//' README.rst
%build
%python_build
%pyproject_wheel
%install
%python_install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
# https://github.com/pytest-dev/pytest-xdist/issues/601
%pytest -k "not test_warning_captured_deprecated_in_pytest_6"
%pytest
%files %{python_files}
%doc CHANGELOG.rst README.rst
%license LICENSE
%{python_sitelib}/xdist
%{python_sitelib}/pytest_xdist-%{version}-py%{python_version}.egg-info
%{python_sitelib}/pytest_xdist-%{version}*-info
%changelog

View File

@ -1,121 +0,0 @@
From ae74dc2172d7f633d2e52d30aec79fbb0ae9ed63 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:26:22 +0200
Subject: [PATCH] Revert "Finish removal of "slave" terminology"
This reverts commit de3e54fd278d49b9b5d64e64f5942512519545e5.
Updated on 2022-01-15
---
setup.cfg | 2 +-
src/xdist/dsession.py | 3 +++
src/xdist/plugin.py | 5 ++++-
src/xdist/remote.py | 3 +++
src/xdist/workermanage.py | 6 +++++-
testing/acceptance_test.py | 16 ++++++++++++++++
6 files changed, 32 insertions(+), 3 deletions(-)
--- a/setup.cfg 2021-12-10 12:41:52.000000000 +0100
+++ b/setup.cfg 2022-01-15 18:37:44.047576974 +0100
@@ -38,7 +38,7 @@ zip_safe = False
python_requires = >=3.6
install_requires =
execnet>=1.1
- pytest>=6.2.0
+ pytest>=4.4.0
pytest-forked
setup_requires = setuptools_scm>=6.0
--- a/src/xdist/dsession.py 2021-12-10 12:41:44.000000000 +0100
+++ b/src/xdist/dsession.py 2022-01-15 18:39:21.407575231 +0100
@@ -155,6 +155,9 @@ class DSession:
node.workerinfo["id"] = node.gateway.id
node.workerinfo["spec"] = node.gateway.spec
+ # TODO: (#234 task) needs this for pytest. Remove when refactor in pytest repo
+ node.slaveinfo = node.workerinfo
+
self.config.hook.pytest_testnodeready(node=node)
if self.shuttingdown:
node.shutdown()
--- a/src/xdist/plugin.py 2021-12-10 12:41:44.000000000 +0100
+++ b/src/xdist/plugin.py 2022-01-15 18:40:33.771573935 +0100
@@ -76,11 +76,14 @@ def pytest_addoption(parser):
)
group.addoption(
"--max-worker-restart",
+ "--max-slave-restart",
action="store",
default=None,
dest="maxworkerrestart",
help="maximum number of workers that can be restarted "
- "when crashed (set to zero to disable this feature)",
+ "when crashed (set to zero to disable this feature)\n"
+ "'--max-slave-restart' option is deprecated and will be removed in "
+ "a future release",
)
group.addoption(
"--dist",
--- a/src/xdist/remote.py 2021-12-10 12:41:44.000000000 +0100
+++ b/src/xdist/remote.py 2022-01-15 18:41:44.115572675 +0100
@@ -287,5 +287,8 @@ if __name__ == "__channelexec__":
config._parser.prog = os.path.basename(workerinput["mainargv"][0])
config.workerinput = workerinput # type: ignore[attr-defined]
config.workeroutput = {} # type: ignore[attr-defined]
+ # TODO: deprecated name, backward compatibility only. Remove it in future
+ config.slaveinput = config.workerinput
+ config.slaveoutput = config.workeroutput
interactor = WorkerInteractor(config, channel) # type: ignore[name-defined]
config.hook.pytest_cmdline_main(config=config)
--- a/src/xdist/workermanage.py 2021-12-10 12:41:44.000000000 +0100
+++ b/src/xdist/workermanage.py 2022-01-15 18:43:34.595570697 +0100
@@ -225,9 +225,13 @@ class WorkerController:
self.workerinput = {
"workerid": gateway.id,
"workercount": len(nodemanager.specs),
+ "slaveid": gateway.id,
+ "slavecount": len(nodemanager.specs),
"testrunuid": nodemanager.testrunuid,
"mainargv": sys.argv,
}
+ # TODO: deprecated name, backward compatibility only. Remove it in future
+ self.slaveinput = self.workerinput
self._down = False
self._shutdown_sent = False
self.log = py.log.Producer("workerctl-%s" % gateway.id)
@@ -329,7 +333,7 @@ class WorkerController:
self.notify_inproc(eventname, node=self, **kwargs)
elif eventname == "workerfinished":
self._down = True
- self.workeroutput = kwargs["workeroutput"]
+ self.workeroutput = self.slaveoutput = kwargs["workeroutput"]
self.notify_inproc("workerfinished", node=self)
elif eventname in ("logstart", "logfinish"):
self.notify_inproc(eventname, node=self, **kwargs)
--- a/testing/acceptance_test.py 2021-12-10 12:41:44.000000000 +0100
+++ b/testing/acceptance_test.py 2022-01-15 18:44:54.711569262 +0100
@@ -247,6 +247,22 @@ class TestDistribution:
result.stderr.fnmatch_lines(["--foobar=123 active! *"])
assert dest.joinpath(subdir.name).is_dir()
+ def test_backward_compatibility_worker_terminology(self, testdir):
+ """Ensure that we still support "config.slaveinput" for backward compatibility (#234).
+
+ Keep in mind that removing this compatibility will break a ton of plugins and user code.
+ """
+ testdir.makepyfile(
+ """
+ def test(pytestconfig):
+ assert hasattr(pytestconfig, 'slaveinput')
+ assert hasattr(pytestconfig, 'workerinput')
+ """
+ )
+ result = testdir.runpytest("-n1")
+ result.stdout.fnmatch_lines("*1 passed*")
+ assert result.ret == 0
+
def test_data_exchange(self, pytester: pytest.Pytester) -> None:
pytester.makeconftest(
"""