commit:     cc6e54e1df5e0802198c793f39107a9028b8698f
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 25 14:01:37 2024 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Apr 25 14:33:19 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cc6e54e1

dev-python/hatchling: Fix test failures without dev-python/uv

Closes: https://bugs.gentoo.org/930662
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/hatchling/hatchling-1.24.2.ebuild | 47 ++++++++++++++++++----------
 1 file changed, 30 insertions(+), 17 deletions(-)

diff --git a/dev-python/hatchling/hatchling-1.24.2.ebuild 
b/dev-python/hatchling/hatchling-1.24.2.ebuild
index 0f7cc99b5b95..5113b4066ed0 100644
--- a/dev-python/hatchling/hatchling-1.24.2.ebuild
+++ b/dev-python/hatchling/hatchling-1.24.2.ebuild
@@ -61,6 +61,31 @@ BDEPEND="
 
 distutils_enable_tests pytest
 
+src_test() {
+       # top-level "tests" directory contains tests both for hatch
+       # and hatchling
+       cd "${WORKDIR}/${MY_P}" || die
+
+       # sigh; standalone test suites are overrated, right?
+       echo "__version__ = '${PV}'" > src/hatch/_version.py || die
+       local -x PYTHONPATH="src:${PYTHONPATH}"
+
+       # do not require uv for portability, sigh
+       mkdir "${T}/bin" || die
+       cat > "${T}/bin/uv" <<-EOF || die
+               #!/bin/sh
+               exit 127
+       EOF
+       chmod +x "${T}/bin/uv" || die
+       local -x PATH=${T}/bin:${PATH}
+
+       # tests mock cargo subprocess call but the backend raises if CARGO
+       # is not set and shutil.which() can't find it
+       local -x CARGO=cargo
+
+       distutils-r1_src_test
+}
+
 python_test() {
        if ! has "${EPYTHON}" "${PYTHON_TESTED[@]/_/.}"; then
                einfo "Skipping tests on ${EPYTHON}"
@@ -68,25 +93,13 @@ python_test() {
        fi
 
        local -x EPYTEST_DESELECT=(
-               # these run pip to install stuff
-               tests/backend/dep/test_core.py::test_dependency_found
-               tests/backend/dep/test_core.py::test_extra_met
-               tests/backend/dep/test_core.py::test_extra_no_dependencies
-               tests/backend/dep/test_core.py::test_extra_unmet
-               tests/backend/dep/test_core.py::test_unknown_extra
-               tests/backend/dep/test_core.py::test_version_unmet
+               # most of these run uv to install stuff
+               # the few remaining tests aren't worth running
+               tests/backend/dep/test_core.py
                # broken if CARGO is set
                
tests/backend/builders/test_binary.py::TestBuildBootstrap::test_no_cargo
        )
 
-       # top-level "tests" directory contains tests both for hatch
-       # and hatchling
-       cd "${WORKDIR}/${MY_P}" || die
-       local -x PYTHONPATH="src:${PYTHONPATH}"
-       # sigh; standalone test suites are overrated, right?
-       echo "__version__ = '${PV}'" > src/hatch/_version.py || die
-       # tests mock cargo subprocess call but the backend raises if CARGO
-       # is not set and shutil.which() can't find it
-       local -x CARGO=cargo
-       epytest tests/backend
+       local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
+       epytest -p pytest_mock tests/backend
 }

Reply via email to