Add an `EPYTEST_PLUGIN_LOAD_VIA_ENV` option to explicitly load plugins
via `PYTEST_PLUGINS` environment variable rather than `-p` options.
This is useful for testing pytest plugins.
While the use case is not very common and therefore may not deserve
explicit eclass support, the value of `PYTEST_PLUGINS` consists
of Python import names that are not trivial to find and have
historically changed across package versions.
Signed-off-by: Michał Górny <
mgorny@gentoo.org>
---
eclass/python-utils-r1.eclass | 62 +++++++++++++++++++++++++----------
1 file changed, 45 insertions(+), 17 deletions(-)
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index bbb57901f281..68faa9e2adf9 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1312,6 +1312,15 @@ _python_check_occluded_packages() {
# The recommended way to disable it in EAPI 8 or earlier is to set
# EPYTEST_PLUGINS (possibly to an empty array).
+# @ECLASS_VARIABLE: EPYTEST_PLUGIN_LOAD_VIA_ENV
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# If set to a non-empty value, plugins will be loaded via PYTEST_PLUGINS
+# environment variable rather than explicit "-p" options. This ensures
+# that plugins are passed down to subprocess, which may be necessary
+# when testing pytest plugins. However, this is also more likely
+# to cause duplicate plugin errors.
+
# @FUNCTION: _set_epytest_plugins
# @INTERNAL
# @DESCRIPTION:
@@ -1442,23 +1451,39 @@ epytest() {