Doc: improve discoverability of passing parameters to fixture functions - #15038
Open
maram-odoo wants to merge 2 commits into
Open
maram-odoo wants to merge 2 commits into
maram-odoo wants to merge 2 commits into
Conversation
The existing mechanism for passing parameters to fixtures via `request.param` and indirect parametrization is functional but hard to discover. This improves discoverability in three ways: 1. Adds a dedicated "Passing arguments to fixture functions" section to the fixtures HOWTO doc (doc/en/how-to/fixtures.rst) that clearly explains the pattern with a worked example. 2. Updates the `@pytest.fixture()` docstring (src/_pytest/fixtures.py) to mention indirect parametrization and point users to the relevant documentation section. 3. Adds a reference label anchor in doc/en/example/parametrize.rst so the :ref:`indirect parametrization` cross-reference resolves correctly from both the fixture docstring and the new HOWTO section. Fixes pytest-dev#8109 Co-authored-by: open-source-contributer <open-source-contributer@hermes.local>
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
request.param+indirect=Truepattern with a worked example@pytest.fixture()docstring to mention indirect parametrization and cross-reference the relevant documentation:ref:indirect parametrization`` label anchor indoc/en/example/parametrize.rstso the cross-reference resolves correctlyFixes #8109
Test plan
make htmlshould render without warnings — verify the new cross-references resolvepython -c "from _pytest.fixtures import fixture; help(fixture)"shows the updatedparams:docstring🤖 Generated with Claude Code