From 0c2e63ade06d6172a1b49afbffd6c959897bc76a Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 26 Jun 2009 22:33:20 +0200 Subject: [PATCH] test case for class decorators --- tests/run/classdecorators_T336.pyx | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/run/classdecorators_T336.pyx diff --git a/tests/run/classdecorators_T336.pyx b/tests/run/classdecorators_T336.pyx new file mode 100644 index 00000000..07444c7b --- /dev/null +++ b/tests/run/classdecorators_T336.pyx @@ -0,0 +1,44 @@ +__doc__ = u""" +>>> print('\\n'.join(calls)) +Py-Honk PyTestClass +PyTestClass +Py-Hello PyTestClass +PyTestClass +Py-Done PyTestClass + +>>> c = PyTestClass() +Ho, Ho, Ho! +""" + +calls = [] + +class print_msg(object): + def __init__(self, message): + self.msg = message + def __call__(self, c): + calls.append( self.msg + c.__name__ ) + return c + +def print_name(c): + calls.append( c.__name__ ) + return c + +@print_msg(u"Py-Done ") +@print_name +@print_msg(u"Py-Hello ") +@print_name +@print_msg(u"Py-Honk ") +class PyTestClass(object): + def __init__(self): + print u"Ho, Ho, Ho!" + +# not currently working: +# +## @print_msg("Cy-Done ") +## @print_name +## @print_msg("Cy-Hello ") +## @print_name +## @print_msg("Cy-Honk ") +## cdef class CyTestClass(object): +## def __init__(self): +## print u"Ho, Ho, Ho!" -- 2.26.2