Mention that pytest_addoption may be used from conftest files
fix #1427
This commit is contained in:
parent
c8ca1d12d7
commit
819e0ead44
|
@ -28,17 +28,14 @@ def pytest_plugin_registered(plugin, manager):
|
||||||
|
|
||||||
@hookspec(historic=True)
|
@hookspec(historic=True)
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
"""register argparse-style options and ini-style config values.
|
"""register argparse-style options and ini-style config values,
|
||||||
|
called once at the beginning of a test run.
|
||||||
|
|
||||||
.. warning::
|
.. note::
|
||||||
|
|
||||||
This function must be implemented in a :ref:`plugin <pluginorder>`
|
This function should be implemented only in plugins or ``conftest.py``
|
||||||
and is called once at the beginning of a test run.
|
files situated at the tests root directory due to how py.test
|
||||||
|
:ref:`discovers plugins during startup <pluginorder>`.
|
||||||
Implementing this hook from ``conftest.py`` files is **strongly**
|
|
||||||
discouraged because ``conftest.py`` files are lazily loaded and
|
|
||||||
may give strange *unknown option* errors depending on the directory
|
|
||||||
``py.test`` is invoked from.
|
|
||||||
|
|
||||||
:arg parser: To add command line options, call
|
:arg parser: To add command line options, call
|
||||||
:py:func:`parser.addoption(...) <_pytest.config.Parser.addoption>`.
|
:py:func:`parser.addoption(...) <_pytest.config.Parser.addoption>`.
|
||||||
|
|
Loading…
Reference in New Issue