summaryrefslogtreecommitdiff
path: root/eclass/python-utils-r1.eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2025-07-05 08:06:42 +0200
committerMichał Górny <mgorny@gentoo.org>2025-07-12 07:05:18 +0200
commit394e3796c6324436920b4406006d23e043d69204 (patch)
tree80306a99b2259b99f5b4956d65aa1150a991ac5b /eclass/python-utils-r1.eclass
parent4bc191233cf98231275dc7a997e6cb67f8c81481 (diff)
downloadgentoo-394e3796c6324436920b4406006d23e043d69204.tar.gz
gentoo-394e3796c6324436920b4406006d23e043d69204.tar.bz2
gentoo-394e3796c6324436920b4406006d23e043d69204.zip
python-utils-r1.eclass: epytest, avoid dupes w/ PYTEST_PLUGINS
Avoid adding duplicate `-p` arguments when the plugin in question is already loaded via `PYTEST_PLUGINS`. This avoids errors when combining dependency adding via `EPYTEST_PLUGINS` with explicit loading via `PYTEST_PLUGINS` (as needed for plugin tests themselves). Signed-off-by: Michał Górny <mgorny@gentoo.org> Part-of: https://github.com/gentoo/gentoo/pull/42876 Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass/python-utils-r1.eclass')
-rw-r--r--eclass/python-utils-r1.eclass5
1 files changed, 4 insertions, 1 deletions
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 9e94acf34edf..bbb57901f281 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1445,12 +1445,15 @@ epytest() {
local plugin_args=()
readarray -t -d '' plugin_args < <(
"${EPYTHON}" - "${EPYTEST_PLUGINS[@]}" <<-EOF || die
+ import os
import sys
from importlib.metadata import distribution, entry_points
+
+ env_plugins = os.environ.get("PYTEST_PLUGINS", "").split(",")
packages = {distribution(x).name for x in sys.argv[1:]}
eps = {
f"-p{x.name}" for x in entry_points(group="pytest11")
- if x.dist.name in packages
+ if x.dist.name in packages and x.value not in env_plugins
}
sys.stdout.write("\\0".join(sorted(eps)))
EOF