summaryrefslogtreecommitdiff
path: root/tests/run/function_as_method_T494.pyx
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run/function_as_method_T494.pyx')
-rw-r--r--tests/run/function_as_method_T494.pyx38
1 files changed, 37 insertions, 1 deletions
diff --git a/tests/run/function_as_method_T494.pyx b/tests/run/function_as_method_T494.pyx
index 34728bc8c..92deafc6d 100644
--- a/tests/run/function_as_method_T494.pyx
+++ b/tests/run/function_as_method_T494.pyx
@@ -1,4 +1,4 @@
-# ticket: 494
+# ticket: t494
# cython: binding=True
__doc__ = """
@@ -12,3 +12,39 @@ class A:
def foo(self):
return self is not None
+
+# assignment of functions used in a "static method" type way behaves differently
+# in Python2 and 3
+import sys
+if sys.version_info[0] == 2:
+ __doc__ = """>>> B.plus1(1) #doctest: +IGNORE_EXCEPTION_DETAIL
+Traceback (most recent call last):
+ ...
+TypeError: unbound
+"""
+else:
+ __doc__ = """>>> B.plus1(1)
+2
+"""
+
+# with binding==False assignment of functions always worked - doesn't match Python
+# behaviour but ensures Cython behaviour stays consistent
+__doc__ += """
+>>> B.plus1_nobind(1)
+2
+"""
+
+cimport cython
+
+def f_plus(a):
+ return a + 1
+
+@cython.binding(False)
+def f_plus_nobind(a):
+ return a+1
+
+cdef class B:
+ plus1 = f_plus
+ plus1_nobind = f_plus_nobind
+
+