summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2021-03-06 11:55:41 +0100
committerMichał Górny <mgorny@gentoo.org>2021-03-08 08:52:30 +0100
commit5130c0197421a125eff7d98c5d0f7ae284acddce (patch)
tree2976a38c7f9b089a0d88f453320c94ec4de8a1c3 /eclass
parentapp-admin/testdisk: Fix building without qtchooser (diff)
downloadgentoo-5130c0197421a125eff7d98c5d0f7ae284acddce.tar.gz
gentoo-5130c0197421a125eff7d98c5d0f7ae284acddce.tar.bz2
gentoo-5130c0197421a125eff7d98c5d0f7ae284acddce.zip
python-utils-r1.eclass: Introduce epytest helper
Introduce an epytest helper to call pytest with the standard set of options, and the standard error message. While distutils_enable_tests made running pytest a lot easier, there are still many cases when python_test() needs to be redefined in order to pass additional options or perform additional actions. Having the extra helper will reduce code duplication and make it easier to change the standard options. Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/python-utils-r1.eclass23
1 files changed, 23 insertions, 0 deletions
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index dcc441b82098..1b2e2ccde8e5 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1278,6 +1278,29 @@ build_sphinx() {
HTML_DOCS+=( "${dir}/_build/html/." )
}
+# @FUNCTION: epytest
+# @USAGE: [<args>...]
+# @DESCRIPTION:
+# Run pytest, passing the standard set of pytest options, followed
+# by user-specified options.
+#
+# This command dies on failure and respects nonfatal in EAPIs supporting
+# nonfatal die.
+epytest() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ [[ -n ${EPYTHON} ]] || die "EPYTHON unset, invalid call context"
+
+ local die_args=()
+ [[ ${EAPI} != [45] ]] && die_args+=( -n )
+
+ set -- "${EPYTHON}" -m pytest -vv "${@}"
+
+ echo "${@}" >&2
+ "${@}" || die "${die_args[@]}" "pytest failed with ${EPYTHON}"
+ return ${?}
+}
+
# -- python.eclass functions --
_python_check_dead_variables() {