Commit 0c2e63ad authored by Stefan Behnel's avatar Stefan Behnel

test case for class decorators

parent 18469076
__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!"
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