MCPcopy
hub / github.com/pytest-dev/pytest / getoption

Method getoption

src/_pytest/config/__init__.py:1923–1946  ·  src/_pytest/config/__init__.py::Config.getoption

Return command line option value. :param name: Name of the option. You may also specify the literal ``--OPT`` option instead of the "dest" option name. :param default: Fallback value if no option of that name is **declared** via :hook:`pytest_addoption`. Note

(self, name: str, default: Any = NOTSET, skip: bool = False)

Source from the content-addressed store, hash-verified

1921 return values
1922
1923 def getoption(self, name: str, default: Any = NOTSET, skip: bool = False):
1924 class="st">"""Return command line option value.
1925
1926 :param name: Name of the option. You may also specify
1927 the literal ``--OPT`` option instead of the class="st">"dest" option name.
1928 :param default: Fallback value if no option of that name is **declared** via :hook:`pytest_addoption`.
1929 Note this parameter will be ignored when the option is **declared** even if the option&class="cm">#x27;s value is ``None``.
1930 :param skip: If ``True``, raise :func:`pytest.skip` if option is undeclared or has a ``None`` value.
1931 Note that even if ``True``, if a default was specified it will be returned instead of a skip.
1932 class="st">"""
1933 name = self._parser._opt2dest.get(name, name)
1934 try:
1935 val = getattr(self.option, name)
1936 if val is None and skip:
1937 raise AttributeError(name)
1938 return val
1939 except AttributeError as e:
1940 if default is not NOTSET:
1941 return default
1942 if skip:
1943 import pytest
1944
1945 pytest.skip(fclass="st">"no {name!r} option found")
1946 raise ValueError(fclass="st">"no option named {name!r}") from e
1947
1948 def getvalue(self, name: str, path=None):
1949 class="st">""class="st">"Deprecated, use getoption() instead."class="st">""

Callers 15

getvalueMethod · 0.95
getvalueorskipMethod · 0.95
get_verbosityMethod · 0.95
capturing_outputFunction · 0.80
get_option_iniFunction · 0.80
_log_cli_enabledMethod · 0.80
__init__Method · 0.80
for_configMethod · 0.80
__init__Method · 0.80
pytest_sessionfinishMethod · 0.80

Calls 1

getMethod · 0.45

Tested by 10

capturing_outputFunction · 0.64
__init__Method · 0.64
_is_doctestFunction · 0.64
repr_failureMethod · 0.64
runtestMethod · 0.64