Skip to content

Commit c3fc717

Browse files
authored
Merge pull request #11843 from bluetech/writing-plugins
doc/writing_plugins: correct inaccuracies re. initial conftest loading
2 parents d71ef04 + 111ad26 commit c3fc717

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

doc/en/how-to/writing_plugins.rst

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,18 @@ Plugin discovery order at tool startup
4646

4747
5. by loading all plugins specified through the :envvar:`PYTEST_PLUGINS` environment variable.
4848

49-
6. by loading all :file:`conftest.py` files as inferred by the command line
50-
invocation:
49+
6. by loading all "initial ":file:`conftest.py` files:
5150

52-
- if no test paths are specified, use the current dir as a test path
53-
- if exists, load ``conftest.py`` and ``test*/conftest.py`` relative
54-
to the directory part of the first test path. After the ``conftest.py``
55-
file is loaded, load all plugins specified in its
56-
:globalvar:`pytest_plugins` variable if present.
51+
- determine the test paths: specified on the command line, otherwise in
52+
:confval:`testpaths` if defined and running from the rootdir, otherwise the
53+
current dir
54+
- for each test path, load ``conftest.py`` and ``test*/conftest.py`` relative
55+
to the directory part of the test path, if exist. Before a ``conftest.py``
56+
file is loaded, load ``conftest.py`` files in all of its parent directories.
57+
After a ``conftest.py`` file is loaded, recursively load all plugins specified
58+
in its :globalvar:`pytest_plugins` variable if present.
5759

58-
Note that pytest does not find ``conftest.py`` files in deeper nested
59-
sub directories at tool startup. It is usually a good idea to keep
60-
your ``conftest.py`` file in the top level test or project root directory.
6160

62-
7. by recursively loading all plugins specified by the
63-
:globalvar:`pytest_plugins` variable in ``conftest.py`` files.
64-
65-
66-
.. _`pytest/plugin`: http://bitbucket.org/pytest-dev/pytest/src/tip/pytest/plugin/
6761
.. _`conftest.py plugins`:
6862
.. _`localplugin`:
6963
.. _`local conftest plugins`:
@@ -108,9 +102,9 @@ Here is how you might run it::
108102
See also: :ref:`pythonpath`.
109103

110104
.. note::
111-
Some hooks should be implemented only in plugins or conftest.py files situated at the
112-
tests root directory due to how pytest discovers plugins during startup,
113-
see the documentation of each hook for details.
105+
Some hooks cannot be implemented in conftest.py files which are not
106+
:ref:`initial <pluginorder>` due to how pytest discovers plugins during
107+
startup. See the documentation of each hook for details.
114108

115109
Writing your own plugin
116110
-----------------------

0 commit comments

Comments
 (0)