Skip to content

Commit 606b2cd

Browse files
committed
Consider entry_points for PYTEST_PLUGINS and pytest_plugins
This fixes two issues related to the `PYTEST_PLUGINS` environment variable and `pytest_plugins` global variable: * plugins loaded this way are not listed in the list of plugins, * it is not possible to load plugins using their names in `entry_points.txt` files. Fixes #12615.
1 parent 400b22d commit 606b2cd

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

Diff for: AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ Mandeep Bhutani
257257
Manuel Krebber
258258
Marc Mueller
259259
Marc Schlaich
260+
Marcel Telka
260261
Marcelo Duarte Trevisani
261262
Marcin Bachry
262263
Marc Bresson

Diff for: changelog/12615.bugfix.rst

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Plugins specified in the :globalvar:`pytest_plugins` config setting and
2+
:envvar:`PYTEST_PLUGINS` environment variable now allow using
3+
:ref:`entry points <pip-installable plugins>` names additionally to the
4+
importable definitions. Prior to this release, these identifiers used to only
5+
work with the ``-p`` CLI option. -- by :user:`mtelka`.

Diff for: doc/en/reference/reference.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ specified plugins will be loaded.
11531153

11541154
.. envvar:: PYTEST_PLUGINS
11551155

1156-
Contains comma-separated list of modules that should be loaded as plugins:
1156+
Contains comma-separated list of modules or entry points that should be loaded as plugins:
11571157

11581158
.. code-block:: bash
11591159

Diff for: src/_pytest/config/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ def _import_plugin_specs(
828828
) -> None:
829829
plugins = _get_plugin_specs_as_list(spec)
830830
for import_spec in plugins:
831-
self.import_plugin(import_spec)
831+
self.import_plugin(import_spec, consider_entry_points=True)
832832

833833
def import_plugin(self, modname: str, consider_entry_points: bool = False) -> None:
834834
"""Import a plugin with ``modname``.

0 commit comments

Comments
 (0)