1
0
python-pytest-xdist/reintroduce-slave-terminology.patch
Matej Cepl c9d5ba2911 Accepting request 946700 from home:buschmann23:branches:devel:languages:python:pytest
- Update to 2.5.0
  * Features
    + Full compatibility with pytest 7 - no deprecation warnings or
      use of legacy features.
    + New --dist=loadgroup option, which ensures all tests marked
      with @pytest.mark.xdist_group run in the same session/worker.
      Other tests run distributed as in --dist=load.
  * Trivial Changes
    + Use @pytest.hookspec decorator to declare hook options in
      newhooks.py to avoid warnings in pytest 7.0.
    + Use up-to-date setup.cfg/pyproject.toml packaging setup.
    + Started using type annotations and mypy checking internally.
      The types are incomplete and not published.
- Changes from 2.4.0
  * Features
    + On Linux, the process title now changes to indicate the current
      worker state (running/idle). Depends on the setproctitle package,
      which can be installed with pip install pytest-xdist[setproctitle].
    + Add support for Python 3.10.
- Changes from 2.3.0
  * Deprecations and Removals
    + Python 3.5 is no longer supported.
  * Features
    + Add --numprocesses=logical flag, which automatically uses the
      number of logical CPUs available, instead of physical CPUs
      with auto. This is very useful for test suites which are not
      CPU-bound.
    + Added new pytest_handlecrashitem hook to allow handling and
      rescheduling crashed items.
  * Bug Fixes
    + Copy the parent process sys.path into local workers, to work
      around execnet's python -c adding the current directory to sys.path.
    + Fix issue caused by changing the branch name of the pytest repository.
  * Trivial Changes
    + Replace master with controller where ever possible.
    + Use 'main' to refer to pytest default branch in tox env names.
- Update patches
  * reintroduce-slave-terminology.patch
  * 0001-Revert-Remove-compat-for-pytest-6.patch
- Require setuptools_scm >= 6.0 for building

OBS-URL: https://build.opensuse.org/request/show/946700
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-xdist?expand=0&rev=26
2022-01-17 06:28:23 +00:00

122 lines
5.0 KiB
Diff

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(
"""