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 <[email protected]> --- eclass/python-utils-r1.eclass | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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() { -- 2.30.1
