From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id CAF3E158F58 for ; Mon, 16 Aug 2021 20:48:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 49E43E09E0; Sun, 15 Aug 2021 06:54:43 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 28385E0901 for ; Sun, 15 Aug 2021 06:54:43 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id F409734405D for ; Sun, 15 Aug 2021 06:54:41 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5D3FA7DE for ; Sun, 15 Aug 2021 06:54:40 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1629010476.a66615fe89a2ab310bc1b778275b0835dbe1faed.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/python-utils-r1.eclass X-VCS-Directories: eclass/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: a66615fe89a2ab310bc1b778275b0835dbe1faed X-VCS-Branch: master Date: Sun, 15 Aug 2021 06:54:40 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 3b9e3462-6534-457c-b6d6-4321997e8a01 X-Archives-Hash: 2f840bfb5bd43f62186891d82c3abf85 commit: a66615fe89a2ab310bc1b778275b0835dbe1faed Author: Michał Górny gentoo org> AuthorDate: Wed Aug 11 07:48:14 2021 +0000 Commit: Michał Górny gentoo org> CommitDate: Sun Aug 15 06:54:36 2021 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a66615fe python-utils-r1.eclass: Handle deselect/ignore in epytest Support (potentially global-scope) EPYTEST_DESELECT and EPYTEST_IGNORE arrays to conveniently deselect/skip tests. This effectively replaces local hacks such as: epytest ${deselect[@]/#/--deselect } Signed-off-by: Michał Górny gentoo.org> eclass/python-utils-r1.eclass | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index a2b5b6d5d41..4fedf939c77 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -1250,11 +1250,30 @@ build_sphinx() { HTML_DOCS+=( "${dir}/_build/html/." ) } +# @VARIABLE: EPYTEST_DESELECT +# @DEFAULT_UNSET +# @DESCRIPTION: +# Specifies an array of tests to be deselected via pytest's --deselect +# parameter, when calling epytest. The list can include file paths, +# specific test functions or parametrized test invocations. +# +# Note that the listed files will still be subject to collection, +# i.e. modules imported in global scope will need to be available. +# If this is undesirable, EPYTEST_IGNORE can be used instead. + +# @VARIABLE: EPYTEST_IGNORE +# @DEFAULT_UNSET +# @DESCRIPTION: +# Specifies an array of paths to be ignored via pytest's --ignore +# parameter, when calling epytest. The listed files will be entirely +# skipped from test collection. + # @FUNCTION: epytest # @USAGE: [...] # @DESCRIPTION: -# Run pytest, passing the standard set of pytest options, followed -# by user-specified options. +# Run pytest, passing the standard set of pytest options, then +# --deselect and --ignore options based on EPYTEST_DESELECT +# and EPYTEST_IGNORE, then user-specified options. # # This command dies on failure and respects nonfatal. epytest() { @@ -1274,6 +1293,13 @@ epytest() { # for end users, as it tends to fail on new warnings from deps -Wdefault ) + local x + for x in "${EPYTEST_DESELECT[@]}"; do + args+=( --deselect "${x}" ) + done + for x in "${EPYTEST_IGNORE[@]}"; do + args+=( --ignore "${x}" ) + done set -- "${EPYTHON}" -m pytest "${args[@]}" "${@}" echo "${@}" >&2