diff --git a/AUTHORS b/AUTHORS index 5c046ff5988..c6331cd022c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -265,6 +265,7 @@ Mandeep Bhutani Manuel Krebber Marc Mueller Marc Schlaich +Marcel Telka Marcelo Duarte Trevisani Marcin Bachry Marc Bresson diff --git a/changelog/12624.improvement.rst b/changelog/12624.improvement.rst new file mode 100644 index 00000000000..7ca60d428dd --- /dev/null +++ b/changelog/12624.improvement.rst @@ -0,0 +1,5 @@ +Plugins specified in the :globalvar:`pytest_plugins` config setting and +:envvar:`PYTEST_PLUGINS` environment variable now allow using +:ref:`entry points ` names additionally to the +importable definitions. Prior to this release, these identifiers used to only +work with the ``-p`` CLI option -- by :user:`mtelka` and :user:`webknjaz`. diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index 26572174ad4..74d28aba431 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -1166,7 +1166,9 @@ specified plugins will be loaded. .. envvar:: PYTEST_PLUGINS -Contains comma-separated list of modules that should be loaded as plugins: +Contains comma-separated list of :term:`importable modules ` +or :ref:`entry point names ` that should be +loaded as plugins: .. code-block:: bash diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 6160f780b1b..8478b43e668 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -826,7 +826,7 @@ def _import_plugin_specs( ) -> None: plugins = _get_plugin_specs_as_list(spec) for import_spec in plugins: - self.import_plugin(import_spec) + self.import_plugin(import_spec, consider_entry_points=True) def import_plugin(self, modname: str, consider_entry_points: bool = False) -> None: """Import a plugin with ``modname``.