commit: fc637105f1fd41e4083db62e524d7d6ef5215166 Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Wed May 21 17:10:28 2025 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Wed May 21 17:10:53 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fc637105
dev-python/forbiddenfruit: Enable (some) testing Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> .../files/forbiddenfruit-0.1.4-pytest.patch | 59 ++++++++++++++++++++++ .../forbiddenfruit/forbiddenfruit-0.1.4.ebuild | 38 ++++++++++++-- 2 files changed, 92 insertions(+), 5 deletions(-) diff --git a/dev-python/forbiddenfruit/files/forbiddenfruit-0.1.4-pytest.patch b/dev-python/forbiddenfruit/files/forbiddenfruit-0.1.4-pytest.patch new file mode 100644 index 000000000000..9d899da70491 --- /dev/null +++ b/dev-python/forbiddenfruit/files/forbiddenfruit-0.1.4-pytest.patch @@ -0,0 +1,59 @@ +From 2022b268f2a537eca27bac10ba74fef35e482d1d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <[email protected]> +Date: Wed, 21 May 2025 18:50:41 +0200 +Subject: [PATCH] Port to pytest + +Port the test suite to pytest, given that nose is unmaintained +and does not work with modern Python versions. This is roughly based +on #47, except that I've modified the `skip_legacy` decorator-variable +in place to make the changes smaller. +--- + Makefile | 3 +-- + development.txt | 3 ++- + tests/unit/test_forbidden_fruit.py | 7 ++++--- + 3 files changed, 7 insertions(+), 6 deletions(-) + +diff --git a/tests/unit/test_forbidden_fruit.py b/tests/unit/test_forbidden_fruit.py +index f8a1b62..7315d1b 100644 +--- a/tests/unit/test_forbidden_fruit.py ++++ b/tests/unit/test_forbidden_fruit.py +@@ -2,7 +2,7 @@ import sys + from datetime import datetime + from forbiddenfruit import cursed, curses, curse, reverse + from types import FunctionType +-from nose.tools import nottest, istest ++import pytest + + # Our stub! :) + from . import ffruit +@@ -14,7 +14,8 @@ def almost_equal(a, b, e=0.001): + return abs(a - b) < e + + +-skip_legacy = nottest if sys.version_info < (3, 3) else istest ++skip_legacy = pytest.mark.skipif(sys.version_info < (3, 3), ++ reason="requires Python < 3.3") + + def test_cursing_a_builtin_class(): + +@@ -186,7 +187,7 @@ def test_dir_without_args_returns_names_in_local_scope(): + + # Then I see that `dir()` correctly returns a sorted list of those names + assert 'some_name' in dir() +- assert dir() == sorted(locals().keys()) ++ assert 'z' in dir() + + + @skip_legacy +diff --git a/tests/unit/test_forbidden_fruit.py b/tests/unit/test_forbidden_fruit.py +index 56b09ce..dd182c6 100644 +--- a/tests/unit/test_forbidden_fruit.py ++++ b/tests/unit/test_forbidden_fruit.py +@@ -319,6 +319,7 @@ def test_dunder_str(): + return 'one' + curse(int, '__str__', always_one) + assert str(1) == "one" ++ reverse(int, '__str__') + + @skip_legacy + def test_dunder_reverse(): diff --git a/dev-python/forbiddenfruit/forbiddenfruit-0.1.4.ebuild b/dev-python/forbiddenfruit/forbiddenfruit-0.1.4.ebuild index 05ef3b30106e..d7de500db155 100644 --- a/dev-python/forbiddenfruit/forbiddenfruit-0.1.4.ebuild +++ b/dev-python/forbiddenfruit/forbiddenfruit-0.1.4.ebuild @@ -4,7 +4,10 @@ EAPI=8 DISTUTILS_USE_PEP517=setuptools -PYTHON_COMPAT=( python3_{11..14} ) +PYTHON_TESTED=( python3_{11..12} ) +# tests crash on 3.13+ +# https://github.com/clarete/forbiddenfruit/issues/78 +PYTHON_COMPAT=( "${PYTHON_TESTED[@]}" python3_{13..14} ) inherit distutils-r1 pypi @@ -17,8 +20,33 @@ HOMEPAGE=" LICENSE="|| ( GPL-3 MIT )" SLOT="0" KEYWORDS="~amd64" -# This is currently tested via dev-python/blockbuster -# TODO: fix a subset of tests to work directly -RESTRICT="test" +IUSE="test" +RESTRICT="!test? ( test )" -#distutils_enable_tests pytest +BDEPEND=" + test? ( + $(python_gen_cond_dep ' + dev-python/pytest[${PYTHON_USEDEP}] + ' "${PYTHON_TESTED[@]}") + ) +" + +PATCHES=( + # https://github.com/clarete/forbiddenfruit/pull/79 + # + test case fix from + # https://github.com/clarete/forbiddenfruit/commit/6eb07cb77bcd3d54c7f09f23f176706d7dfccdef + "${FILESDIR}/${P}-pytest.patch" +) + +python_test() { + if ! has "${EPYTHON/./_}" "${PYTHON_TESTED[@]}"; then + einfo "Skipping tests on ${EPYTHON}, as they are broken" + return + fi + + local -x FFRUIT_EXTENSION=true + esetup.py build_ext -b tests/unit + + local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 + epytest +}
