diff options
-rw-r--r-- | tests/run/__getattribute__.pyx | 18 | ||||
-rw-r--r-- | tests/run/__getattribute_subclasses__.pyx | 60 | ||||
-rw-r--r-- | tests/run/special_methods_T561.pyx | 8 |
3 files changed, 43 insertions, 43 deletions
diff --git a/tests/run/__getattribute__.pyx b/tests/run/__getattribute__.pyx index bc36c5808..e7af8b033 100644 --- a/tests/run/__getattribute__.pyx +++ b/tests/run/__getattribute__.pyx @@ -14,9 +14,9 @@ cdef class just_getattribute: 'bar' >>> a.called 4 - >>> a.invalid - Traceback (most recent call last): - AttributeError + >>> try: a.invalid + ... except AttributeError: pass + ... else: print("NOT RAISED!") >>> a.called 6 """ @@ -46,9 +46,9 @@ cdef class just_getattr: 'bar' >>> a.called 1 - >>> a.invalid - Traceback (most recent call last): - AttributeError + >>> try: a.invalid + ... except AttributeError: pass + ... else: print("NOT RAISED!") >>> a.called 2 """ @@ -77,9 +77,9 @@ cdef class both: 'bar' >>> (a.called_getattr, a.called_getattribute) (1, 8) - >>> a.invalid - Traceback (most recent call last): - AttributeError + >>> try: a.invalid + ... except AttributeError: pass + ... else: print("NOT RAISED!") >>> (a.called_getattr, a.called_getattribute) (2, 11) """ diff --git a/tests/run/__getattribute_subclasses__.pyx b/tests/run/__getattribute_subclasses__.pyx index 61bb90828..a0048876a 100644 --- a/tests/run/__getattribute_subclasses__.pyx +++ b/tests/run/__getattribute_subclasses__.pyx @@ -22,9 +22,9 @@ cdef class getattr_boring(boring): getattr_boring >>> a.getattr_called 1 - >>> a.no_such_member - Traceback (most recent call last): - AttributeError + >>> try: a.no_such_member + ... except AttributeError: pass + ... else: print("FAILED!") >>> a.getattr_called 2 """ @@ -51,18 +51,18 @@ cdef class getattribute_boring(boring): >>> a = getattribute_boring() >>> a.getattribute_called 1 - >>> a.boring_member - Traceback (most recent call last): - AttributeError + >>> try: a.boring_member + ... except AttributeError: pass + ... else: print("FAILED!") >>> a.getattribute_called 3 >>> print(a.resolved_by) getattribute_boring >>> a.getattribute_called 5 - >>> a.no_such_member - Traceback (most recent call last): - AttributeError + >>> try: a.no_such_member + ... except AttributeError: pass + ... else: print("FAILED!") >>> a.getattribute_called 7 """ @@ -114,9 +114,9 @@ class getattr_py(_getattr): True >>> a.getattr_called 2 - >>> a.no_such_member - Traceback (most recent call last): - AttributeError + >>> try: a.no_such_member + ... except AttributeError: pass + ... else: print("FAILED!") # currently fails, see #1793 #>>> a.getattr_called @@ -153,9 +153,9 @@ class getattribute_py(_getattribute): True >>> a.getattribute_called 5 - >>> a.no_such_member - Traceback (most recent call last): - AttributeError + >>> try: a.no_such_member + ... except AttributeError: pass + ... else: print("FAILED!") >>> a.getattribute_called 7 """ @@ -171,23 +171,23 @@ cdef class boring_boring_getattribute(boring_getattribute): >>> a = boring_boring_getattribute() >>> a.getattribute_called 1 - >>> a.boring_getattribute_member - Traceback (most recent call last): - AttributeError + >>> try: a.boring_getattribute_member + ... except AttributeError: pass + ... else: print("FAILED!") >>> a.getattribute_called 3 - >>> a.boring_boring_getattribute_member - Traceback (most recent call last): - AttributeError + >>> try: a.boring_boring_getattribute_member + ... except AttributeError: pass + ... else: print("FAILED!") >>> a.getattribute_called 5 >>> print(a.resolved_by) _getattribute >>> a.getattribute_called 7 - >>> a.no_such_member - Traceback (most recent call last): - AttributeError + >>> try: a.no_such_member + ... except AttributeError: pass + ... else: print("FAILED!") >>> a.getattribute_called 9 """ @@ -225,9 +225,9 @@ cdef class getattribute_boring_boring_getattr(boring_boring_getattr): True >>> (a.getattr_called, a.getattribute_called) (5, 11) - >>> a.no_such_member - Traceback (most recent call last): - AttributeError + >>> try: a.no_such_member + ... except AttributeError: pass + ... else: print("FAILED!") >>> (a.getattr_called, a.getattribute_called) (7, 14) """ @@ -270,9 +270,9 @@ cdef class getattr_boring_boring_getattribute(boring_boring_getattribute): True >>> (a.getattr_called, a.getattribute_called) (5, 11) - >>> a.no_such_member - Traceback (most recent call last): - AttributeError + >>> try: a.no_such_member + ... except AttributeError: pass + ... else: print("FAILED!") >>> (a.getattr_called, a.getattribute_called) (7, 14) """ diff --git a/tests/run/special_methods_T561.pyx b/tests/run/special_methods_T561.pyx index a314370a0..63d8b7254 100644 --- a/tests/run/special_methods_T561.pyx +++ b/tests/run/special_methods_T561.pyx @@ -53,10 +53,10 @@ __doc__ = u""" >>> g01 = object.__getattribute__(GetAttr(), '__getattribute__') >>> g01('attr') GetAttr getattr 'attr' - >>> g10 = object.__getattribute__(GetAttribute(), '__getattr__') # doctest: +ELLIPSIS - Traceback (most recent call last): - ... - AttributeError: 'special_methods_T561.GetAttribute' object has no attribute '__getattr__'... + >>> try: object.__getattribute__(GetAttribute(), '__getattr__') + ... except AttributeError as err: + ... assert '__getattr__' in str(err), err + ... else: print("NOT RAISED!") >>> g11 = object.__getattribute__(GetAttribute(), '__getattribute__') >>> g11('attr') GetAttribute getattribute 'attr' |