commit:     e3c29d283259fc96a539b6884da2050d583ca9fa
Author:     Lucio Sauer <watermanpaint <AT> posteo <DOT> net>
AuthorDate: Sun Feb 25 01:12:23 2024 +0000
Commit:     Julien Roy <julien <AT> jroy <DOT> ca>
CommitDate: Sun Feb 25 01:19:25 2024 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=e3c29d28

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 <AT> posteo.net>

 .../pytest-mypy-plugins-2.0.0.ebuild                 |  7 ++++++-
 .../pytest-mypy-plugins-3.0.0.ebuild                 | 20 +++++++++++++++-----
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/dev-python/pytest-mypy-plugins/pytest-mypy-plugins-2.0.0.ebuild 
b/dev-python/pytest-mypy-plugins/pytest-mypy-plugins-2.0.0.ebuild
index a3bf16184b..9f71cfe5bc 100644
--- a/dev-python/pytest-mypy-plugins/pytest-mypy-plugins-2.0.0.ebuild
+++ b/dev-python/pytest-mypy-plugins/pytest-mypy-plugins-2.0.0.ebuild
@@ -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
+}

diff --git a/dev-python/pytest-mypy-plugins/pytest-mypy-plugins-3.0.0.ebuild 
b/dev-python/pytest-mypy-plugins/pytest-mypy-plugins-3.0.0.ebuild
index 4dea09aa89..db59ede98f 100644
--- a/dev-python/pytest-mypy-plugins/pytest-mypy-plugins-3.0.0.ebuild
+++ b/dev-python/pytest-mypy-plugins/pytest-mypy-plugins-3.0.0.ebuild
@@ -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
 }

Reply via email to