From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-dev] [PATCH 3/6] distutils-r1.eclass: Add distutils_enable_tests import-check
Date: Fri, 19 Jul 2024 16:56:03 +0200 [thread overview]
Message-ID: <20240719150427.133877-4-mgorny@gentoo.org> (raw)
In-Reply-To: <20240719150427.133877-1-mgorny@gentoo.org>
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@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
;;
--
2.45.2
next prev parent reply other threads:[~2024-07-19 15:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-19 14:56 [gentoo-dev] [PATCH 0/6] distutils-r1.eclass: Enable wheel reuse by default and add `distutils_enable_tests import-check` Michał Górny
2024-07-19 14:56 ` [gentoo-dev] [PATCH 1/6] distutils-r1.eclass: Fix QA to ignore non-generic "pure" wheels Michał Górny
2024-07-19 14:56 ` [gentoo-dev] [PATCH 2/6] distutils-r1.eclass: Allow wheel reuse by default Michał Górny
2024-07-19 14:56 ` Michał Górny [this message]
2024-07-19 14:56 ` [gentoo-dev] [PATCH 4/6] dev-python/ytmusicapi: Enable import-check testing (sample) Michał Górny
2024-07-19 14:56 ` [gentoo-dev] [PATCH 5/6] dev-python/pymountboot: " Michał Górny
2024-07-19 14:56 ` [gentoo-dev] [PATCH 6/6] dev-python/miniupnpc: " Michał Górny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240719150427.133877-4-mgorny@gentoo.org \
--to=mgorny@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox