pytest icon indicating copy to clipboard operation
pytest copied to clipboard

Consider entry points for `PYTEST_PLUGINS` and `pytest_plugins`

Open mtelka opened this issue 1 year ago • 0 comments

What's the problem this feature will solve?

Currently it is not possible to load plugins via PYTEST_PLUGINS/pytest_plugins using their entry points. Only module names are recognized.

Describe the solution you'd like

The simple add of consider_entry_points=True to the self.import_plugin() call in the _import_plugin_specs() allows to load plugins using their entry points.

See also https://github.com/pytest-dev/pytest/issues/12615#issuecomment-2229774683

Alternative Solutions

It is possible to use different ways to load plugins (like -p option), but alternatives have other drawbacks. For example list of plugins loaded using -p is not passed down to runpytest() calls.

It is also possible to use module names in PYTEST_PLUGINS/pytest_plugins, but this would need to use not so well known plugin names and it also does have a problem that plugins loaded this way are not listed in the test report (bug #12615).

Additional context

N/A

mtelka avatar Jul 16 '24 18:07 mtelka