Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document bootstrap and initialization hooks #3091

Merged
merged 1 commit into from
Jan 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions _pytest/hookspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ def pytest_configure(config):

# -------------------------------------------------------------------------
# Bootstrapping hooks called for plugins registered early enough:
# internal and 3rd party plugins as well as directly
# discoverable conftest.py local plugins.
# internal and 3rd party plugins.
# -------------------------------------------------------------------------


Expand All @@ -96,6 +95,9 @@ def pytest_cmdline_parse(pluginmanager, args):

Stops at first non-None result, see :ref:`firstresult`

.. note::
This hook will not be called for ``conftest.py`` files, only for setuptools plugins.

:param _pytest.config.PytestPluginManager pluginmanager: pytest plugin manager
:param list[str] args: list of arguments passed on the command line
"""
Expand All @@ -107,6 +109,9 @@ def pytest_cmdline_preparse(config, args):
This hook is considered deprecated and will be removed in a future pytest version. Consider
using :func:`pytest_load_initial_conftests` instead.

.. note::
This hook will not be called for ``conftest.py`` files, only for setuptools plugins.

:param _pytest.config.Config config: pytest config object
:param list[str] args: list of arguments passed on the command line
"""
Expand All @@ -117,6 +122,9 @@ def pytest_cmdline_main(config):
""" called for performing the main command line action. The default
implementation will invoke the configure hooks and runtest_mainloop.

.. note::
This hook will not be called for ``conftest.py`` files, only for setuptools plugins.

Stops at first non-None result, see :ref:`firstresult`

:param _pytest.config.Config config: pytest config object
Expand All @@ -127,6 +135,9 @@ def pytest_load_initial_conftests(early_config, parser, args):
""" implements the loading of initial conftest files ahead
of command line option parsing.

.. note::
This hook will not be called for ``conftest.py`` files, only for setuptools plugins.

:param _pytest.config.Config early_config: pytest config object
:param list[str] args: list of arguments passed on the command line
:param _pytest.config.Parser parser: to add command line options
Expand Down
13 changes: 12 additions & 1 deletion doc/en/writing_plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -583,11 +583,22 @@ pytest hook reference
Initialization, command line and configuration hooks
----------------------------------------------------

Bootstrapping hooks
~~~~~~~~~~~~~~~~~~~

Bootstrapping hooks called for plugins registered early enough (internal and setuptools plugins).

.. autofunction:: pytest_load_initial_conftests
.. autofunction:: pytest_cmdline_preparse
.. autofunction:: pytest_cmdline_parse
.. autofunction:: pytest_addoption
.. autofunction:: pytest_cmdline_main

Initialization hooks
~~~~~~~~~~~~~~~~~~~~

Initialization hooks called for plugins and ``conftest.py`` files.

.. autofunction:: pytest_addoption
.. autofunction:: pytest_configure
.. autofunction:: pytest_unconfigure

Expand Down