Skip to content

Fix --last-failed for custom item names containing brackets - #15065

Open
SIBTAIN-ASAD wants to merge 7 commits into
pytest-dev:mainfrom
SIBTAIN-ASAD:fix-lastfailed-custom-bracket-names-15045
Open

SIBTAIN-ASAD wants to merge 7 commits into
pytest-dev:mainfrom
SIBTAIN-ASAD:fix-lastfailed-custom-bracket-names-15045

Conversation

@SIBTAIN-ASAD

Copy link
Copy Markdown

Fixes #15045.

Custom collectors can create item names that contain brackets, such as a_bad[one]. The --last-failed cache stores the string nodeid, but reparsing that string treats the bracketed portion as parameters. The structured id then no longer compares equal to the live custom item, so a later --lf run can skip the still-failing item and report success.

This keeps the cache keys in their original string form and compares collected/report ids using their canonical string representation. Paths still use NodeId.parse() only when deriving the files that contain previous failures.

Verification:

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --frozen pytest --override-ini=minversion=0 testing/test_cacheprovider.py -q — 69 passed
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --frozen pytest --override-ini=minversion=0 testing/test_cacheprovider.py testing/python/fixtures.py testing/python/show_fixtures_per_test.py -q — 327 passed, 3 xfailed
  • uvx --from ruff ruff check src/_pytest/cacheprovider.py testing/test_cacheprovider.py
  • uvx --from ruff ruff format --check src/_pytest/cacheprovider.py testing/test_cacheprovider.py
  • git diff --check

@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Sep 19, 2026
@SemTiOne

Copy link
Copy Markdown
Contributor

Dup of #15046?

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

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--last-failed can silently skip failing custom items with brackets in their names

2 participants