diff options
Diffstat (limited to 'tests/run/function_as_method_py_T494.py')
-rw-r--r-- | tests/run/function_as_method_py_T494.py | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/run/function_as_method_py_T494.py b/tests/run/function_as_method_py_T494.py index 49d5f27ce..5317d8848 100644 --- a/tests/run/function_as_method_py_T494.py +++ b/tests/run/function_as_method_py_T494.py @@ -1,4 +1,4 @@ -# ticket: 494 +# ticket: t494 __doc__ = """ >>> A.foo = foo @@ -11,3 +11,35 @@ 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__ = u""" +>>> B.plus1(1) #doctest: +IGNORE_EXCEPTION_DETAIL +Traceback (most recent call last): + ... +TypeError: unbound +>>> C.plus1(1) #doctest: +IGNORE_EXCEPTION_DETAIL +Traceback (most recent call last): + ... +TypeError: unbound +""" +else: + __doc__ = u""" +>>> B.plus1(1) +2 +>>> C.plus1(1) +2 +""" + +def f_plus(a): + return a + 1 + +class B: + plus1 = f_plus + +class C(object): + plus1 = f_plus |