Skip to content

Fix loadscope handling of colons in parameters - #1382

Open
LouisDeconinck wants to merge 3 commits into
pytest-dev:masterfrom
LouisDeconinck:fix/loadscope-param-colons-1335
Open

LouisDeconinck wants to merge 3 commits into
pytest-dev:masterfrom
LouisDeconinck:fix/loadscope-param-colons-1335

Conversation

@LouisDeconinck

Copy link
Copy Markdown

Fixes #1335.

LoadScopeScheduling._split_scope previously split on the last ::, so a parametrized value containing :: could be mistaken for the test scope. Parse the module boundary first and only consider :: separators before parametrization, preserving class-level grouping.

Added regression coverage for colon-containing parameters and parameterized class methods.

Checks:

  • Reasonable regression tests added
  • Towncrier changelog fragment added
  • pytest -q testing (224 passed, 6 skipped, 10 xfailed)
  • ruff check and ruff format --check
  • git diff --check

pytest-dev/pytest#14758 (main, upcoming 9.2) replaced Node._nodeid with a
structured NodeId stored in Node._id, so assigning item._nodeid no longer
affects item.nodeid and xdist_group suffixes were silently dropped.

When Node._id is present, override the NodeId's cached string form so
item.nodeid (and reports, which share the object) carry the @group
suffix as before.
@LouisDeconinck

Copy link
Copy Markdown
Author

Pushed a fix for the py311-pytestmain CI failures.

The failing TestGroupScope tests were unrelated to the loadscope change: pytest main (pytest-dev/pytest#14758, upcoming 9.2) replaced the Node._nodeid string with a structured NodeId object in Node._id, so item._nodeid = ... in remote.py silently wrote a dead attribute and the @group suffix never reached the scheduler — every test became its own scope.

The commit detects Node._id and overrides the NodeId's cached string form instead, so item.nodeid (and reports, which share the object) still carry the @group suffix; released pytest keeps the existing _nodeid path. Full testing/ suite passes locally against both pytest main and pytest 9.1.1.

Note this affects master too — happy to split it into a separate PR if preferred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

loadscope bug: :: in test parameters breaks scope detection

1 participant