commit: 80a7960b9faa73152efd81e316f1083644817a02
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 16 16:21:09 2024 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Jul 22 15:09:32 2024 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=80a7960b
distutils-r1.eclass: Add distutils_enable_tests import-check
Add support for using the dev-python/pytest-import-check plugin to
test if all modules installed by the package can be imported.
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
eclass/distutils-r1.eclass | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 645b5df5a6e5..fa8edb5cdfb7 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -572,6 +572,9 @@ distutils_enable_sphinx() {
# with the specified test runner. Also copies the current value
# of RDEPEND to test?-BDEPEND. The test-runner argument must be one of:
#
+# - import-check: `pytest --import-check` fallback (for use when there are
+# no tests to run)
+#
# - pytest: dev-python/pytest
#
# - setup.py: setup.py test (no deps included)
@@ -597,9 +600,13 @@ distutils_enable_tests() {
[[ ${#} -eq 1 ]] || die "${FUNCNAME} takes exactly one argument:
test-runner"
local test_deps=${RDEPEND}
+ local test_pkgs=
case ${1} in
+ import-check)
+ test_pkgs+='
dev-python/pytest-import-check[${PYTHON_USEDEP}]'
+ ;&
pytest)
- local
test_pkgs='>=dev-python/pytest-7.4.4[${PYTHON_USEDEP}]'
+ test_pkgs+='
>=dev-python/pytest-7.4.4[${PYTHON_USEDEP}]'
if [[ -n ${EPYTEST_TIMEOUT} ]]; then
test_pkgs+='
dev-python/pytest-timeout[${PYTHON_USEDEP}]'
fi
@@ -1560,6 +1567,9 @@ distutils-r1_python_test() {
_python_check_EPYTHON
case ${_DISTUTILS_TEST_RUNNER} in
+ import-check)
+ epytest --import-check
"${BUILD_DIR}/install$(python_get_sitedir)"
+ ;;
pytest)
epytest
;;