From cd857184d6adaf6afd7725df21e1dbefd8191ecc Mon Sep 17 00:00:00 2001 From: Cornelius Riemenschneider Date: Wed, 21 Aug 2024 16:02:53 +0200 Subject: [PATCH 1/2] Make node ID modification more stable. We force test collection on the controller node, as we run some global setup there before starting the workers. That setup also depends on the test node IDs, but currently, pytest-xdist only modifies the test node IDs on the workers, that've been started and where `setup_config` has been called. I don't see a good reason for this, and for creating a separate config entry, so let's just check the right condition in the pytest hook. That way, the hook will always do the same node ID transformation, regardless of pytest-xdist setup. --- src/xdist/remote.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/xdist/remote.py b/src/xdist/remote.py index dd1f9883..6f244f46 100644 --- a/src/xdist/remote.py +++ b/src/xdist/remote.py @@ -207,7 +207,7 @@ def pytest_collection_modifyitems( items: list[pytest.Item], ) -> None: # add the group name to nodeid as suffix if --dist=loadgroup - if config.getvalue("loadgroup"): + if config.getoption("dist") == "loadgroup": for item in items: mark = item.get_closest_marker("xdist_group") if not mark: @@ -356,7 +356,6 @@ def getinfodict() -> WorkerInfo: def setup_config(config: pytest.Config, basetemp: str | None) -> None: - config.option.loadgroup = config.getvalue("dist") == "loadgroup" config.option.looponfail = False config.option.usepdb = False config.option.dist = "no" From 6b7156a8b0e95a3e8720ac8f4f1cdf3f9ae3529b Mon Sep 17 00:00:00 2001 From: Cornelius Riemenschneider Date: Wed, 21 Aug 2024 16:11:02 +0200 Subject: [PATCH 2/2] Add changelog. --- changelog/1118.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/1118.bugfix diff --git a/changelog/1118.bugfix b/changelog/1118.bugfix new file mode 100644 index 00000000..1d984b68 --- /dev/null +++ b/changelog/1118.bugfix @@ -0,0 +1 @@ +Loadgroup: Always apply the node ID transformation, even if test collection is run on the controller node.