diff --git a/bin/tests/system/conftest.py b/bin/tests/system/conftest.py index 5e8473e424..678327a31f 100644 --- a/bin/tests/system/conftest.py +++ b/bin/tests/system/conftest.py @@ -62,6 +62,30 @@ PRIORITY_TESTS_RE = Re("|".join(PRIORITY_TESTS)) SYSTEM_TEST_NAME_RE = Re(f"{SYSTEM_TEST_DIR_GIT_PATH}" + r"/([^/]+)") SYMLINK_REPLACEMENT_RE = Re(r"/tests_(.*)\.py") +# ---- Fix pytest-xdist loadscope for node IDs containing "::" ---------- + +# LoadScopeScheduling._split_scope uses rsplit("::", 1) which breaks when +# test parameters contain "::" (e.g. IPv6 addresses like "cafe:cafe::cafe"). +# This causes tests from the same file to be assigned to different workers, +# each paying the full fixture setup cost. Override to split on ".py::" +# which is unambiguous. +# https://github.com/pytest-dev/pytest-xdist/issues/1335 +try: + from xdist.scheduler.loadscope import LoadScopeScheduling + + # pylint: disable=protected-access + _orig_split_scope = LoadScopeScheduling._split_scope + + def _fixed_split_scope(self, nodeid): + if ".py::" in nodeid: + return nodeid.split(".py::")[0] + ".py" + return _orig_split_scope(self, nodeid) + + LoadScopeScheduling._split_scope = _fixed_split_scope + # pylint: enable=protected-access +except ImportError: + pass + # --------------------------- pytest hooks -------------------------------