Skip to content

Conversation

@FazeelUsmani
Copy link

Fixes #13304

The documentation in "Writing hook functions" incorrectly suggested that hook implementations in conftest.py files are accessible during pytest_addoption() execution. This led to confusion when developers tried to use conftest hooks to provide default values for plugin options.

Changes

  • Updated the example in the "Using hooks in pytest_addoption" section to show a third-party plugin instead of a conftest.py file
  • Added a clear warning note explaining that conftest.py hooks are not available during pytest_addoption() because conftest files are discovered and loaded after plugin initialization
  • Documented which plugin types ARE available during pytest_addoption():
    • builtin plugins
    • plugins explicitly loaded with -p on the command line
    • installed third-party plugins (via setuptools entry points)
    • plugins specified via the PYTEST_PLUGINS environment variable
  • Added cross-reference to the plugin discovery order documentation

Testing

  • Documentation-only change, no code behavior modified
  • Verified RST syntax is correct
  • Confirmed all cross-references are valid
  • Changelog entry created: changelog/13304.doc.rst

@FazeelUsmani FazeelUsmani marked this pull request as draft November 12, 2025 13:18
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Nov 12, 2025
@FazeelUsmani FazeelUsmani marked this pull request as ready for review November 12, 2025 13:46
Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial conftests are considered

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.

Doc on conftest.py hook interactions with pytest_addoption() possibly misleading

2 participants