Skip to content

Commit afb8a4e

Browse files
committed
Document bootstrap and initialization hooks
Fix pytest-dev#2616
1 parent 06a1823 commit afb8a4e

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

_pytest/hookspec.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ def pytest_configure(config):
8585

8686
# -------------------------------------------------------------------------
8787
# Bootstrapping hooks called for plugins registered early enough:
88-
# internal and 3rd party plugins as well as directly
89-
# discoverable conftest.py local plugins.
88+
# internal and 3rd party plugins.
9089
# -------------------------------------------------------------------------
9190

9291

@@ -96,6 +95,9 @@ def pytest_cmdline_parse(pluginmanager, args):
9695
9796
Stops at first non-None result, see :ref:`firstresult`
9897
98+
.. note::
99+
This hook will not be called for ``conftest.py`` files, only for setuptools plugins.
100+
99101
:param _pytest.config.PytestPluginManager pluginmanager: pytest plugin manager
100102
:param list[str] args: list of arguments passed on the command line
101103
"""
@@ -107,6 +109,9 @@ def pytest_cmdline_preparse(config, args):
107109
This hook is considered deprecated and will be removed in a future pytest version. Consider
108110
using :func:`pytest_load_initial_conftests` instead.
109111
112+
.. note::
113+
This hook will not be called for ``conftest.py`` files, only for setuptools plugins.
114+
110115
:param _pytest.config.Config config: pytest config object
111116
:param list[str] args: list of arguments passed on the command line
112117
"""
@@ -117,6 +122,9 @@ def pytest_cmdline_main(config):
117122
""" called for performing the main command line action. The default
118123
implementation will invoke the configure hooks and runtest_mainloop.
119124
125+
.. note::
126+
This hook will not be called for ``conftest.py`` files, only for setuptools plugins.
127+
120128
Stops at first non-None result, see :ref:`firstresult`
121129
122130
:param _pytest.config.Config config: pytest config object
@@ -127,6 +135,9 @@ def pytest_load_initial_conftests(early_config, parser, args):
127135
""" implements the loading of initial conftest files ahead
128136
of command line option parsing.
129137
138+
.. note::
139+
This hook will not be called for ``conftest.py`` files, only for setuptools plugins.
140+
130141
:param _pytest.config.Config early_config: pytest config object
131142
:param list[str] args: list of arguments passed on the command line
132143
:param _pytest.config.Parser parser: to add command line options

doc/en/writing_plugins.rst

+12-1
Original file line numberDiff line numberDiff line change
@@ -583,11 +583,22 @@ pytest hook reference
583583
Initialization, command line and configuration hooks
584584
----------------------------------------------------
585585

586+
Bootstrapping hooks
587+
~~~~~~~~~~~~~~~~~~~
588+
589+
Bootstrapping hooks called for plugins registered early enough (internal and setuptools plugins).
590+
586591
.. autofunction:: pytest_load_initial_conftests
587592
.. autofunction:: pytest_cmdline_preparse
588593
.. autofunction:: pytest_cmdline_parse
589-
.. autofunction:: pytest_addoption
590594
.. autofunction:: pytest_cmdline_main
595+
596+
Initialization hooks
597+
~~~~~~~~~~~~~~~~~~~~
598+
599+
Initialization hooks called for plugins and ``conftest.py`` files.
600+
601+
.. autofunction:: pytest_addoption
591602
.. autofunction:: pytest_configure
592603
.. autofunction:: pytest_unconfigure
593604

0 commit comments

Comments
 (0)