Skip to content

fix: resolve doctest locations for fixture definitions#14702

Merged
RonnyPfannschmidt merged 3 commits into
pytest-dev:mainfrom
vetrovk:fix/doctest-fixture-line-number
Jul 21, 2026
Merged

fix: resolve doctest locations for fixture definitions#14702
RonnyPfannschmidt merged 3 commits into
pytest-dev:mainfrom
vetrovk:fix/doctest-fixture-line-number

Conversation

@vetrovk

@vetrovk vetrovk commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #14700.

Summary

Starting with pytest 8.4, @pytest.fixture returns a FixtureFunctionDefinition. On Python 3.12, doctest line discovery could return None for that wrapper. A skipped fixture doctest then caused an internal error during report creation.

This reuses the existing wrapper-unwrapping behavior before doctest line lookup. Report generation and assertions in reports.py remain unchanged.

Validation

  • tox -e py312 -- testing/test_doctest.py
  • tox -e py312 -- testing/test_doctest.py::TestDoctests::test_fixture_doctest_skip_has_line_number
  • pre-commit run --files src/_pytest/doctest.py testing/test_doctest.py changelog/14700.bugfix.rst
  • git diff --check
  • Manual fixture-doctest reproducer and the original jaraco.test scenario on Python 3.12

Checklist

  • Include documentation when adding new features.
  • Include new tests or update existing tests when applicable.
  • Allow maintainers to push and squash when merging my commits.
  • Add text like Fixes #14700 to the PR description and/or commits.
  • AI agents were used and are credited in the commit's Co-authored-by trailer.
  • Create a new changelog file in the changelog directory.

Co-authored-by: OpenAI Codex <noreply@openai.com>
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Jul 13, 2026
@RonnyPfannschmidt
RonnyPfannschmidt merged commit e7355d7 into pytest-dev:main Jul 21, 2026
36 checks passed
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.

line is not None assertion in reports.py failing in jaraco.test, since pytest 8.4, on Python 3.12

3 participants