1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
From: =?utf-8?b?TWljaGHFgiBHw7Nybnk=?= <mgorny@gentoo.org>
Date: Wed, 21 May 2025 18:50:41 +0200
Subject: 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.
Origin: other, https://github.com/clarete/forbiddenfruit/pull/79
Last-Update: 2025-08-28
---
Makefile | 3 +--
development.txt | 3 ++-
tests/unit/test_forbidden_fruit.py | 7 ++++---
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
index 52ed607..6e36208 100644
--- a/Makefile
+++ b/Makefile
@@ -25,8 +25,7 @@ run_test:
@if [ -d tests/$(suite) ]; then \
echo "Running \033[0;32m$(suite)\033[0m test suite"; \
make prepare; \
- nosetests --stop --with-coverage --cover-package=$(PACKAGE) \
- --cover-branches --verbosity=2 -s tests/$(suite) ; \
+ pytest --cov=$(PACKAGE) -vv tests/$(suite) ; \
fi
prepare: clean install_deps build_test_stub
diff --git a/development.txt b/development.txt
index 7b37a21..6c5ad5b 100644
--- a/development.txt
+++ b/development.txt
@@ -1,4 +1,5 @@
-r requirements.txt
-nose==1.2.1
coverage==3.6
tox==1.4.3
+pytest
+pytest-cov
diff --git a/tests/unit/test_forbidden_fruit.py b/tests/unit/test_forbidden_fruit.py
index 56b09ce..109e9ae 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
|