Skip to content

Commit f324b27

Browse files
authored
Merge pull request #7748 from nicoddemus/fix-plugin-order-docs
Improve docs about plugin discovery/loading at startup
2 parents 28ba9ab + 7324e90 commit f324b27

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

doc/en/writing_plugins.rst

+22-14
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,34 @@ Plugin discovery order at tool startup
3333

3434
``pytest`` loads plugin modules at tool startup in the following way:
3535

36-
* by loading all builtin plugins
36+
1. by scanning the command line for the ``-p no:name`` option
37+
and *blocking* that plugin from being loaded (even builtin plugins can
38+
be blocked this way). This happens before normal command-line parsing.
3739

38-
* by loading all plugins registered through `setuptools entry points`_.
40+
2. by loading all builtin plugins.
3941

40-
* by pre-scanning the command line for the ``-p name`` option
41-
and loading the specified plugin before actual command line parsing.
42+
3. by scanning the command line for the ``-p name`` option
43+
and loading the specified plugin. This happens before normal command-line parsing.
4244

43-
* by loading all :file:`conftest.py` files as inferred by the command line
44-
invocation:
45+
4. by loading all plugins registered through `setuptools entry points`_.
4546

46-
- if no test paths are specified use current dir as a test path
47-
- if exists, load ``conftest.py`` and ``test*/conftest.py`` relative
48-
to the directory part of the first test path.
47+
5. by loading all plugins specified through the :envvar:`PYTEST_PLUGINS` environment variable.
4948

50-
Note that pytest does not find ``conftest.py`` files in deeper nested
51-
sub directories at tool startup. It is usually a good idea to keep
52-
your ``conftest.py`` file in the top level test or project root directory.
49+
6. by loading all :file:`conftest.py` files as inferred by the command line
50+
invocation:
5351

54-
* by recursively loading all plugins specified by the
55-
:globalvar:`pytest_plugins` variable in ``conftest.py`` files
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.
57+
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.
61+
62+
7. by recursively loading all plugins specified by the
63+
:globalvar:`pytest_plugins` variable in ``conftest.py`` files.
5664

5765

5866
.. _`pytest/plugin`: http://bitbucket.org/pytest-dev/pytest/src/tip/pytest/plugin/

0 commit comments

Comments
 (0)