Repository navigation
Parse loadscope scopes with pytest's nodeid grammar - #1413
Open
RonnyPfannschmidt wants to merge 2 commits into
Open
RonnyPfannschmidt wants to merge 2 commits into
RonnyPfannschmidt wants to merge 2 commits into
Conversation
`LoadScopeScheduling._split_scope` used `nodeid.rsplit("::", 1)`, so a
`::` inside a parametrization id (e.g. IPv6 addresses) split a module or
class into several work units.
Parse the nodeid the way pytest does: the first `::` ends the path, the
first `[` after it starts the parametrization id, and the scope is the
path plus all names but the last. This also handles non-.py items,
unbalanced brackets in ids and `[` in paths.
Fixes #1335. Supersedes #1350 and #1382; their test cases are reused.
Co-authored-by: itscloud0 <89895960+itscloud0@users.noreply.github.com>
Co-authored-by: Louis Deconinck <27673665+LouisDeconinck@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014GZsREv63hfLhYEKWU14vE
RonnyPfannschmidt
requested review from
nicoddemus
and
a balanced review from Copilot
November 19, 2026 07:19
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the loadscope scope-parsing fix.
No open issues 🎉
What changed in this PR
Fixes #1335 by making loadscope scope parsing follow pytest’s nodeid grammar, keeping tests grouped by module or class when parameter IDs contain ::.
Changes:
- Separates the path and test names before ignoring parametrization content.
- Adds parser regressions for bracket and separator edge cases, plus a two-worker grouping acceptance test.
- Documents the fix in a changelog fragment.
| File | Description |
|---|---|
| testing/acceptance_test.py | Adds scope-parsing cases and verifies module grouping with :: parameter IDs. |
| src/xdist/scheduler/loadscope.py | Updates scope parsing and its documentation to follow pytest’s nodeid grammar. |
| changelog/1335.bugfix.rst | Records the loadscope grouping fix. |
Review effort: Balanced
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014GZsRFm6asVUgAJ3erG6Nu
5 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Ronny · project thread
🤖 Written by Claude Opus 5.5 via Claude Code for the pytest-xdist maintainers; I prompted it, it did the work, I read it.
Fixes #1335. Supersedes #1350 and #1382; both authors are credited as co-authors and their test cases are reused.
LoadScopeScheduling._split_scopeusednodeid.rsplit("::", 1), so a::inside a parametrization id (IPv6 addresses, for example) split one module or class into several work units.This PR parses the nodeid the way pytest's own
NodeId.parsedoes (pytest-dev/pytest#14758). The first::ends the path, and the first[after it starts the parametrization id. The scope is the path plus every name except the last.Compared with the two earlier PRs:
x]::y) or a path contains[(dir[/a.py)..py::) still uses the old split for non-.py items (yaml and similar plugins). It also carries a loadgroup change that Fix loadgroup with pytest main node IDs #1388 has since made obsolete.All of these cases are covered by
TestLoadScope::test_split_scope. There is also an acceptance test with::ids under-n2 --dist=loadscope. Both fail on master and pass with this change.changelog/1335.bugfix.rstLocal runs: full
testing/suite passes on pytest 9.1.1. On pytest main, the only failure istest_remote_usage_prog, which also fails on master; it comes from an untagged local pytest checkout. pre-commit is clean on the changed files.Generated by Claude Code