summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2020-03-22 20:40:16 +0100
committerStefan Behnel <stefan_ml@behnel.de>2020-03-22 20:40:16 +0100
commitf055a66ca99f0eee874995312ca0392698238ebb (patch)
tree418d84bb81849b331547418ebf416e2785099a70
parentff2dfa0b5a5f2cb1a2e6636f5c54f69bd16ed492 (diff)
downloadcython-gh2564_enable_binding.tar.gz
Try to work around some test issues in PyPy3:gh2564_enable_binding
- CyFunction seems to lead to deeper stacks on recursion. - Passing integers through call layers can end up creating new int objects instead of keeping the identical objects ('is' test fails)'.
-rw-r--r--tests/run/isnot.pyx11
-rw-r--r--tests/run/knuth_man_or_boy_test.pyx6
2 files changed, 13 insertions, 4 deletions
diff --git a/tests/run/isnot.pyx b/tests/run/isnot.pyx
index 9baabbc7e..f7efd017d 100644
--- a/tests/run/isnot.pyx
+++ b/tests/run/isnot.pyx
@@ -3,12 +3,17 @@
cimport cython
+# Use a single global object for identity checks.
+# PyPy can optimise away integer objects, for example, and may fail the 'is' test.
+obj = object()
+
+
@cython.test_fail_if_path_exists('//NotNode')
def is_not(a, b):
"""
>>> is_not(1, 2)
True
- >>> x = 1
+ >>> x = obj
>>> is_not(x, x)
False
"""
@@ -20,7 +25,7 @@ def not_is_not(a, b):
"""
>>> not_is_not(1, 2)
False
- >>> x = 1
+ >>> x = obj
>>> not_is_not(x, x)
True
"""
@@ -32,7 +37,7 @@ def not_is(a, b):
"""
>>> not_is(1, 2)
True
- >>> x = 1
+ >>> x = obj
>>> not_is(x, x)
False
"""
diff --git a/tests/run/knuth_man_or_boy_test.pyx b/tests/run/knuth_man_or_boy_test.pyx
index 068cec524..d2b5c8825 100644
--- a/tests/run/knuth_man_or_boy_test.pyx
+++ b/tests/run/knuth_man_or_boy_test.pyx
@@ -46,9 +46,13 @@ def compute(val):
def a(in_k, x1, x2, x3, x4, x5):
"""
>>> import sys
- >>> sys.setrecursionlimit(1350)
+ >>> old_limit = sys.getrecursionlimit()
+ >>> sys.setrecursionlimit(1350 if not getattr(sys, 'pypy_version_info', None) else 2700)
+
>>> a(10, 1, -1, -1, 1, 0)
-67
+
+ >>> sys.setrecursionlimit(old_limit)
"""
k = [in_k]
def b():