dev-python/pytest-mypy-plugins: workaround mypy-related test failure

Fix upstreamed: https://github.com/typeddjango/pytest-mypy-plugins/issues/137

Closes: https://bugs.gentoo.org/921901
Signed-off-by: Lucio Sauer <watermanpaint@posteo.net>
This commit is contained in:
Lucio Sauer
2024-02-25 02:12:23 +01:00
parent dfeb4b154a
commit e3c29d2832
2 changed files with 21 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
# Copyright 2023 Gentoo Authors
# Copyright 2023-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
@@ -32,3 +32,8 @@ RDEPEND="
"
distutils_enable_tests pytest
python_test() {
# --mypy-only-local-stub is a workaround for bug #921901
epytest --mypy-only-local-stub
}

View File

@@ -1,4 +1,4 @@
# Copyright 2023 Gentoo Authors
# Copyright 2023-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
@@ -34,9 +34,19 @@ RDEPEND="
distutils_enable_tests pytest
python_test() {
# Calling pytest directly causes module not to be imported correctly
sed "s/\"pytest\"/\"${EPYTHON}\", \"-m\", \"pytest\"/" \
python_prepare_all() {
# tests need pytest_mypy_plugins.tests on the modules search path and
# python -m pytest preprends sys.path with ${PWD}/${S}
# --mypy-only-local-stub is a workaround for bug #921901
sed "s/\"pytest\"/\"MY_EPYTHON\", \"-m\", \"pytest\", \"--mypy-only-local-stub\"/" \
-i pytest_mypy_plugins/tests/test_explicit_configs.py || die
distutils-r1_python_test
distutils-r1_python_prepare_all
}
python_test() {
# substitute the correct interpreter
sed "s/MY_EPYTHON/${EPYTHON}/" -i pytest_mypy_plugins/tests/test_explicit_configs.py || die
epytest --mypy-only-local-stub
# reset for next interpreter run
sed "s/${EPYTHON}/MY_EPYTHON/" -i pytest_mypy_plugins/tests/test_explicit_configs.py || die
}