Skip to content

Commit

Permalink
Fix ambiguous docstring of pytest.Config
Browse files Browse the repository at this point in the history
For full context see issue pytest-dev#10558
  • Loading branch information
sus-pe committed Oct 11, 2024
1 parent f373974 commit 412be41
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog/10558.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix ambiguous docstring of `pytest.Config.getoption`.
9 changes: 6 additions & 3 deletions src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1695,13 +1695,16 @@ def _get_override_ini_value(self, name: str) -> str | None:
return value

def getoption(self, name: str, default=notset, skip: bool = False):
"""Return command line option value.
"""Return command line option value if exists
An option "exists" if the parser has been taught to expect it using parser.addoption in pytest_addoption hook.
:param name: Name of the option. You may also specify
the literal ``--OPT`` option instead of the "dest" option name.
:param default: Default value if no option of that name exists.
:param default: Default value if no option of that name exists (see note on option existence).
If an option exists then this parameter will be ignored even if the option's value is None.
:param skip: If True, raise pytest.skip if option does not exists
or has a None value.
or has a None value. In case the option name doesn't exist,
but a default param was passed, then the default will be returned instead of a skip.
"""
name = self._opt2dest.get(name, name)
try:
Expand Down

0 comments on commit 412be41

Please sign in to comment.