aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2022-12-03 10:42:01 +0200
committerMatti Picus <matti.picus@gmail.com>2022-12-03 10:42:01 +0200
commit59af01eca3d8dd99e0d41f8e07608059f2a62e94 (patch)
tree406d9bfeae5037290df6f4f3a5a81030c032355c
parentremove more redundant tests, sync better with upstream (diff)
downloadpypy-release-pypy3.9-v7.3.10.tar.gz
pypy-release-pypy3.9-v7.3.10.tar.bz2
pypy-release-pypy3.9-v7.3.10.zip
fix tests for no c_functoolsrelease-pypy3.9-v7.3.10
-rw-r--r--lib-python/3/test/test_functools.py37
1 files changed, 22 insertions, 15 deletions
diff --git a/lib-python/3/test/test_functools.py b/lib-python/3/test/test_functools.py
index 31e5f0f333..1c169c790d 100644
--- a/lib-python/3/test/test_functools.py
+++ b/lib-python/3/test/test_functools.py
@@ -199,7 +199,9 @@ class TestPartial:
kwargs = {'a': object(), 'b': object()}
kwargs_reprs = ['a={a!r}, b={b!r}'.format_map(kwargs),
'b={b!r}, a={a!r}'.format_map(kwargs)]
- if self.partial in (c_functools.partial, py_functools.partial):
+ if c_functools and self.partial is c_functools.partial:
+ name = 'functools.partial'
+ elif self.partial is py_functools.partial:
name = 'functools.partial'
else:
name = self.partial.__name__
@@ -221,7 +223,9 @@ class TestPartial:
for kwargs_repr in kwargs_reprs])
def test_recursive_repr(self):
- if self.partial in (c_functools.partial, py_functools.partial):
+ if c_functools and self.partial is c_functools.partial:
+ name = 'functools.partial'
+ elif self.partial is py_functools.partial:
name = 'functools.partial'
else:
name = self.partial.__name__
@@ -1753,9 +1757,10 @@ class TestLRU:
def py_cached_func(x, y):
return 3 * x + y
-@c_functools.lru_cache()
-def c_cached_func(x, y):
- return 3 * x + y
+if c_functools:
+ @c_functools.lru_cache()
+ def c_cached_func(x, y):
+ return 3 * x + y
class TestLRUPy(TestLRU, unittest.TestCase):
@@ -1772,18 +1777,20 @@ class TestLRUPy(TestLRU, unittest.TestCase):
return 3 * x + y
-class TestLRUC(TestLRU, unittest.TestCase):
- module = c_functools
- cached_func = c_cached_func,
+if c_functools:
+ @unittest.skipUnless(c_functools, 'requires the C _functools module')
+ class TestLRUC(TestLRU, unittest.TestCase):
+ module = c_functools
+ cached_func = c_cached_func,
- @module.lru_cache()
- def cached_meth(self, x, y):
- return 3 * x + y
+ @module.lru_cache()
+ def cached_meth(self, x, y):
+ return 3 * x + y
- @staticmethod
- @module.lru_cache()
- def cached_staticmeth(x, y):
- return 3 * x + y
+ @staticmethod
+ @module.lru_cache()
+ def cached_staticmeth(x, y):
+ return 3 * x + y
class TestSingleDispatch(unittest.TestCase):