Skip to content

Commit

Permalink
Merge pull request #1433 from nicoddemus/issue-1427
Browse files Browse the repository at this point in the history
Mention that pytest_addoption may be used from conftest files

fixes #1427
  • Loading branch information
RonnyPfannschmidt committed Mar 4, 2016
2 parents c8ca1d1 + 819e0ea commit 3884398
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions _pytest/hookspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,14 @@ def pytest_plugin_registered(plugin, manager):

@hookspec(historic=True)
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>`
and is called once at the beginning of a test run.
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.
This function should be implemented only in plugins or ``conftest.py``
files situated at the tests root directory due to how py.test
:ref:`discovers plugins during startup <pluginorder>`.
:arg parser: To add command line options, call
:py:func:`parser.addoption(...) <_pytest.config.Parser.addoption>`.
Expand Down

0 comments on commit 3884398

Please sign in to comment.