mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-09 00:43:21 -04:00
fix: test: Fix pytest-xdist loadscope splitting on "::" in params
LoadScopeScheduling._split_scope() uses rsplit("::", 1) to
extract the test file scope from a node ID. When parametrized
test values contain "::" (IPv6 addresses like "cafe:cafe::cafe"
or "::1"), the split lands inside the parameter instead of at
the .py:: boundary. This creates spurious scopes that get
assigned to different workers, each triggering a full fixture
setup (starting named instances).
Override _split_scope() in conftest.py to split on ".py::"
which is unambiguous.
Six tests in synthrecord/tests_synthrecord.py are affected.
A verification script is included in util/.
Assisted-by: Claude:claude-opus-4-7
Merge branch 'mnowak/fix-xdist-loadscope-split' into 'main'
See merge request isc-projects/bind9!12103
This commit is contained in:
commit
11e204ee00
1 changed files with 24 additions and 0 deletions
|
|
@ -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 -------------------------------
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue