Commit e8a5b5fc authored by Stefan Behnel's avatar Stefan Behnel

test case cleanup

parent ecf22d5a
__doc__ = u""" __doc__ = u"""
__getattribute__ and __getattr__ special methods for a single class. __getattribute__ and __getattr__ special methods for a single class.
"""
cdef class just_getattribute:
"""
>>> a = just_getattribute() >>> a = just_getattribute()
>>> a.bar >>> a.bar
'bar' 'bar'
>>> a.invalid >>> a.invalid
Traceback (most recent call last): Traceback (most recent call last):
AttributeError AttributeError
"""
def __getattribute__(self,n):
if n == 'bar':
return n
else:
raise AttributeError
cdef class just_getattr:
"""
>>> a = just_getattr() >>> a = just_getattr()
>>> a.foo >>> a.foo
10 10
...@@ -16,25 +27,7 @@ __getattribute__ and __getattr__ special methods for a single class. ...@@ -16,25 +27,7 @@ __getattribute__ and __getattr__ special methods for a single class.
>>> a.invalid >>> a.invalid
Traceback (most recent call last): Traceback (most recent call last):
AttributeError AttributeError
"""
>>> a = both()
>>> a.foo
10
>>> a.bar
'bar'
>>> a.invalid
Traceback (most recent call last):
AttributeError
"""
cdef class just_getattribute:
def __getattribute__(self,n):
if n == 'bar':
return n
else:
raise AttributeError
cdef class just_getattr:
cdef readonly int foo cdef readonly int foo
def __init__(self): def __init__(self):
self.foo = 10 self.foo = 10
...@@ -45,6 +38,16 @@ cdef class just_getattr: ...@@ -45,6 +38,16 @@ cdef class just_getattr:
raise AttributeError raise AttributeError
cdef class both: cdef class both:
"""
>>> a = both()
>>> a.foo
10
>>> a.bar
'bar'
>>> a.invalid
Traceback (most recent call last):
AttributeError
"""
cdef readonly int foo cdef readonly int foo
def __init__(self): def __init__(self):
self.foo = 10 self.foo = 10
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment