Skip to content

Fix automatic parameter IDs for broken __name__ lookup#14569

Open
marko1olo wants to merge 1 commit into
pytest-dev:mainfrom
marko1olo:fix-param-id-name-keyerror
Open

Fix automatic parameter IDs for broken __name__ lookup#14569
marko1olo wants to merge 1 commit into
pytest-dev:mainfrom
marko1olo:fix-param-id-name-keyerror

Conversation

@marko1olo
Copy link
Copy Markdown

Fixes #14560.

Summary

  • use pytest's defensive safe_getattr helper when automatic parametrization ID generation probes __name__
  • fall back to the argument/index ID when a parameter value raises during __name__ lookup
  • add a regression test and changelog fragment

Verification

  • red before fix: python -m pytest testing\python\metafunc.py::TestMetafunc::test_idval_ignores_broken_name_attribute -q failed with KeyError: '__name__'
  • python -m pytest testing\python\metafunc.py::TestMetafunc::test_idval_ignores_broken_name_attribute -q
  • python -m pytest testing\python\metafunc.py -q
  • python -m ruff check src\_pytest\python.py testing\python\metafunc.py
  • python -m ruff format --check src\_pytest\python.py testing\python\metafunc.py
  • git diff --check

@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Jun 6, 2026
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.

Pytest can't handle custom classes in parameterized tests (major bug).

1 participant