MCPcopy Create free account
hub / github.com/pytest-dev/pytest / pytest_addoption

Function pytest_addoption

src/_pytest/hookspec.py:82–117  ·  view source on GitHub ↗

Register argparse-style options and ini-style config values, called once at the beginning of a test run. .. note:: This function should be implemented only in plugins or ``conftest.py`` files situated at the tests root directory due to how pytest :ref:`discovers plu

(parser: "Parser", pluginmanager: "PytestPluginManager")

Source from the content-addressed store, hash-verified

80
81@hookspec(historic=True)
82def pytest_addoption(parser: "Parser", pluginmanager: "PytestPluginManager") -> None:
83 """Register argparse-style options and ini-style config values,
84 called once at the beginning of a test run.
85
86 .. note::
87
88 This function should be implemented only in plugins or ``conftest.py``
89 files situated at the tests root directory due to how pytest
90 :ref:`discovers plugins during startup <pluginorder>`.
91
92 :param pytest.Parser parser:
93 To add command line options, call
94 :py:func:`parser.addoption(...) <pytest.Parser.addoption>`.
95 To add ini-file values call :py:func:`parser.addini(...)
96 <pytest.Parser.addini>`.
97
98 :param pytest.PytestPluginManager pluginmanager:
99 The pytest plugin manager, which can be used to install :py:func:`hookspec`&#x27;s
100 or :py:func:`hookimpl`'s and allow one plugin to call another plugin's hooks
101 to change how command line options are added.
102
103 Options can later be accessed through the
104 :py:class:`config <pytest.Config>` object, respectively:
105
106 - :py:func:`config.getoption(name) <pytest.Config.getoption>` to
107 retrieve the value of a command line option.
108
109 - :py:func:`config.getini(name) <pytest.Config.getini>` to retrieve
110 a value read from an ini-style file.
111
112 The config object is passed around on many internal objects via the ``.config``
113 attribute or can be retrieved as the ``pytestconfig`` fixture.
114
115 .. note::
116 This hook is incompatible with ``hookwrapper=True``.
117 """
118
119
120@hookspec(historic=True)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected