From 5130c0197421a125eff7d98c5d0f7ae284acddce Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Sat, 6 Mar 2021 11:55:41 +0100 Subject: python-utils-r1.eclass: Introduce epytest helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- eclass/python-utils-r1.eclass | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'eclass') 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: [...] +# @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() { -- cgit v1.2.3-65-gdbad