docs: fix misleading docstring about default vs skip=True in getoption #13879
+20
−6
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.
This PR clarifies the
pytest.Config.getoptiondocstring to make the exceptional behavior ofdefaultwithskip=Trueexplicit.Also adds a small test verifying that behavior.
Stituation before this change
The previous docstring implied:
defaultparameter is ignored when the option is declared.But actual behavior is:
defaultis not ignored even if the option is declared, whenskip=Trueand the option hasNonevalue.This can be reproduced by the following test case (already existing in
testing/test_config.py):Rationale
The
getoption()behavior involves multiple conditions (whether the option is declared or not,Noneor not,default,skip), which previously made the docstring easy to misinterpret. This PR avoids multiple "note that ..." caveats and keeps each parameter’s description self-contained and readable.skip=Truespecial case in plain language.pytest_addoptionhook was removed, since this method’s behavior is independent of how the option was added.**declared**was removed.Nonevalue (context: Improve pytest.Config.getoption docstring #12886). The new wording states this condition explicitly.default=Noneandskip=True.Notes
No behavior change; documentation and test addition only.
Related historical issue: #10558