1
0
python-pytest-xdist/reintroduce-slave-terminology.patch
Markéta Machová e064f81a24 Accepting request 830842 from home:mcalabkova:branches:devel:languages:python:pytest
- Update to 2.1.0
  * New ``pytest_xdist_auto_num_workers`` hook can be implemented by plugins 
    or ``conftest.py`` files to control the number of workers when 
    ``--numprocesses=auto`` is given in the command-line.
  * ``psutil`` has proven to make ``pytest-xdist`` installation in certain 
    platforms and containers problematic, so to use it for automatic number 
    of CPUs detection users need to install the ``psutil`` extra
- Add patches to keep compatibility with older pytests:
  * reintroduce-slave-terminology.patch
  * 0001-Revert-Remove-compat-for-pytest-6.patch

OBS-URL: https://build.opensuse.org/request/show/830842
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-xdist?expand=0&rev=20
2020-08-31 14:15:07 +00:00

146 lines
5.6 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.
---
.appveyor.yml | 1 +
.travis.yml | 2 ++
setup.py | 10 ++++++----
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 ++++++++++++++++
tox.ini | 4 ++++
9 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/setup.py b/setup.py
index b6fb0f1..560069c 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages
-install_requires = ["execnet>=1.1", "pytest>=6.0.0", "pytest-forked"]
+install_requires = ["execnet>=1.1", "pytest>=4.4.0", "pytest-forked"]
with open("README.rst") as f:
@@ -9,7 +9,8 @@ with open("README.rst") as f:
setup(
name="pytest-xdist",
use_scm_version={"write_to": "src/xdist/_version.py"},
- description="pytest xdist plugin for distributed testing and loop-on-failing modes",
+ description="pytest xdist plugin for distributed testing"
+ " and loop-on-failing modes",
long_description=long_description,
license="MIT",
author="holger krekel and contributors",
diff --git a/src/xdist/dsession.py b/src/xdist/dsession.py
index 07ef091..80edd9b 100644
--- a/src/xdist/dsession.py
+++ b/src/xdist/dsession.py
@@ -150,6 +150,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()
diff --git a/src/xdist/plugin.py b/src/xdist/plugin.py
index 2d8424d..f497603 100644
--- a/src/xdist/plugin.py
+++ b/src/xdist/plugin.py
@@ -65,11 +65,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",
diff --git a/src/xdist/remote.py b/src/xdist/remote.py
index 97dc180..26cf958 100644
--- a/src/xdist/remote.py
+++ b/src/xdist/remote.py
@@ -233,5 +233,8 @@ if __name__ == "__channelexec__":
config._parser.prog = os.path.basename(workerinput["mainargv"][0])
config.workerinput = workerinput
config.workeroutput = {}
+ # TODO: deprecated name, backward compatibility only. Remove it in future
+ config.slaveinput = config.workerinput
+ config.slaveoutput = config.workeroutput
interactor = WorkerInteractor(config, channel)
config.hook.pytest_cmdline_main(config=config)
diff --git a/src/xdist/workermanage.py b/src/xdist/workermanage.py
index dfcb59b..9b00251 100644
--- a/src/xdist/workermanage.py
+++ b/src/xdist/workermanage.py
@@ -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)
@@ -326,7 +330,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)
diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py
index 48ed35f..8cac669 100644
--- a/testing/acceptance_test.py
+++ b/testing/acceptance_test.py
@@ -241,6 +241,22 @@ class TestDistribution:
result.stderr.fnmatch_lines(["--foobar=123 active! *"])
assert dest.join(subdir.basename).check(dir=1)
+ 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, testdir):
testdir.makeconftest(
"""
--
2.28.0