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 }