commit:     1ded69a8ae9c41da9bf7da03b65fdb2ec38a9376
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 21 21:06:56 2021 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jun 21 21:19:20 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1ded69a8

dev-python/agate: Replace pytest-expect with pure bash

Replace pytest-expect with pure bash in order to use
the preferred skipping-tests-based-on-paths-names recipe
via epytest --deselect arguments, and also add the missing
epytest die call reported by David Seifert.

The included pytest-expect-to-deselect function can
perhaps be migrated to an eclass somewhere:

# @FUNCTION: pytest-expect-to-deselect
# @USAGE: readarray -t pytest_args < <(pytest-expect-to-deselect 
<<<PYTEST_EXPECT_CONTENT)
# @DESCRIPTION:
# Read a pytest-expect pytest --xfail-file file from stdin and write
# equivalent pytest --deselect arguments to stdout for consumption by
# readarray -t. The generated pytest --deselect arguments are appropriate
# for use as described here:
# 
https://dev.gentoo.org/~mgorny/python-guide/pytest.html#skipping-tests-based-on-paths-names
pytest-expect-to-deselect() {
        while read -r; do
                [[ ${REPLY} =~ ^[u]?\'([^\']*) ]] || continue
                printf -- '%s\n' --deselect "${BASH_REMATCH[1]}" || return
        done
}

See: 
https://dev.gentoo.org/~mgorny/python-guide/pytest.html#skipping-tests-based-on-paths-names
Bug: https://bugs.gentoo.org/797307
Reported-by: Michał Górny <mgorny <AT> gentoo.org>
Reported-by: David Seifert <soap <AT> gentoo.org>
Package-Manager: Portage-3.0.20, Repoman-3.0.3
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 dev-python/agate/agate-1.6.2.ebuild | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/dev-python/agate/agate-1.6.2.ebuild 
b/dev-python/agate/agate-1.6.2.ebuild
index 6c3fd2a618f..25dfaf8d73d 100644
--- a/dev-python/agate/agate-1.6.2.ebuild
+++ b/dev-python/agate/agate-1.6.2.ebuild
@@ -25,20 +25,32 @@ RDEPEND="
        >=dev-python/python-slugify-1.2.1[${PYTHON_USEDEP}]
        >=dev-python/leather-0.3.2[${PYTHON_USEDEP}]
 "
-BDEPEND="
-       test? (
-               dev-python/pytest-expect[${PYTHON_USEDEP}]
-       )
-"
 
 distutils_enable_tests pytest
 
-python_prepare_all() {
-       cat > .pytest.expect <<-EOF
+# @FUNCTION: pytest-expect-to-deselect
+# @USAGE: readarray -t pytest_args < <(pytest-expect-to-deselect 
<<<PYTEST_EXPECT_CONTENT)
+# @DESCRIPTION:
+# Read a pytest-expect pytest --xfail-file file from stdin and write
+# equivalent pytest --deselect arguments to stdout for consumption by
+# readarray -t. The generated pytest --deselect arguments are appropriate
+# for use as described here:
+# 
https://dev.gentoo.org/~mgorny/python-guide/pytest.html#skipping-tests-based-on-paths-names
+pytest-expect-to-deselect() {
+       while read -r; do
+               [[ ${REPLY} =~ ^[u]?\'([^\']*) ]] || continue
+               printf -- '%s\n' --deselect "${BASH_REMATCH[1]}" || return
+       done
+}
+
+python_test() {
+       local -a pytest_args
+       readarray -t pytest_args < <(pytest-expect-to-deselect <<<"
 pytest-expect file v1
 (3, 8, 10, 'final', 0)
 u'tests/test_data_types.py::TestDate::test_cast_format_locale': FAIL
 u'tests/test_data_types.py::TestDateTime::test_cast_format_locale': FAIL
-EOF
-       distutils-r1_python_prepare_all
+")
+
+       epytest "${pytest_args[@]}" || die
 }

Reply via email to