From e8a5b5fc9b79d5fa59774e324829ff67f71dd608 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sun, 18 Oct 2009 14:52:43 +0200 Subject: [PATCH] test case cleanup --- tests/run/__getattribute__.pyx | 41 ++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/tests/run/__getattribute__.pyx b/tests/run/__getattribute__.pyx index ea71bc2c..9a97341e 100644 --- a/tests/run/__getattribute__.pyx +++ b/tests/run/__getattribute__.pyx @@ -1,13 +1,24 @@ __doc__ = u""" __getattribute__ and __getattr__ special methods for a single class. +""" +cdef class just_getattribute: + """ >>> a = just_getattribute() >>> a.bar 'bar' >>> a.invalid Traceback (most recent call last): AttributeError + """ + def __getattribute__(self,n): + if n == 'bar': + return n + else: + raise AttributeError +cdef class just_getattr: + """ >>> a = just_getattr() >>> a.foo 10 @@ -16,25 +27,7 @@ __getattribute__ and __getattr__ special methods for a single class. >>> a.invalid Traceback (most recent call last): 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 def __init__(self): self.foo = 10 @@ -45,6 +38,16 @@ cdef class just_getattr: raise AttributeError cdef class both: + """ + >>> a = both() + >>> a.foo + 10 + >>> a.bar + 'bar' + >>> a.invalid + Traceback (most recent call last): + AttributeError + """ cdef readonly int foo def __init__(self): self.foo = 10 -- 2.26.2