Skip to content

Handle :: in loadscope parametrized ids#1350

Open
itscloud0 wants to merge 2 commits into
pytest-dev:masterfrom
itscloud0:fix-1335-loadscope-nodeid-splitting
Open

Handle :: in loadscope parametrized ids#1350
itscloud0 wants to merge 2 commits into
pytest-dev:masterfrom
itscloud0:fix-1335-loadscope-nodeid-splitting

Conversation

@itscloud0

Copy link
Copy Markdown

Problem

Fixes #1335.

LoadScopeScheduling._split_scope() currently takes the last :: in the nodeid without accounting for parametrized ids. Values like ::1 or cafe:cafe::cafe make --dist=loadscope split a single module into multiple work units, so related tests can be scattered across workers and pay repeated fixture setup costs.

Solution

Track the last top-level :: outside parametrization brackets when deriving the loadscope key.

This keeps the existing class-vs-module grouping behavior, while ignoring :: that only appear inside parametrized ids. I also added:

  • a parser-level regression for function and class-method nodeids
  • an acceptance test showing parametrized IPv6 ids stay grouped per module under --dist=loadscope
  • the required changelog fragment

Verification

  • python -m pytest testing/test_loadscope.py -q
  • python -m pytest testing/acceptance_test.py -q -k 'test_by_module or test_by_class or test_by_module_with_double_colons_in_parametrize_ids'
  • python -m ruff check src/xdist/scheduler/loadscope.py testing/acceptance_test.py testing/test_loadscope.py

Limitations

This only changes loadscope scope parsing. loadfile and loadgroup behavior is unchanged.

@itscloud0 itscloud0 marked this pull request as ready for review July 6, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

loadscope bug: :: in test parameters breaks scope detection

1 participant