From: Stefan Behnel Date: Sun, 8 Mar 2009 13:18:27 +0000 (+0100) Subject: test case for ticket #18 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b34b20d4f670b965a643c540823b4698297cc4d0;p=cython.git test case for ticket #18 --- diff --git a/tests/bugs/class_attribute_init_values_T18.pyx b/tests/bugs/class_attribute_init_values_T18.pyx new file mode 100644 index 00000000..7372275a --- /dev/null +++ b/tests/bugs/class_attribute_init_values_T18.pyx @@ -0,0 +1,55 @@ +__doc__ = u""" +>>> f = PyFoo() +>>> print(f.bar) +5 +>>> print(f.baz) +someval + +>>> f = MyPyFoo() +>>> print(f.bar) +7 +>>> print(f.baz) +anotherval + +>>> f = CyFoo() +>>> print(f.bar) +5 +>>> print(f.baz) +anotherval + +>>> f = MyCyFoo() +>>> print(f.bar) +7 +>>> print(f.baz) +anotherval + +>>> f = AnotherFoo() +>>> print(f.bar) +8 +>>> print(f.baz) +yetanotherval +""" + +# this works: + +class PyFoo(object): + bar = 5 + baz = u"someval" + +class MyPyFoo(PyFoo): + bar = 7 + baz = u"anotherval" + +# this doesn't: + +cdef class CyFoo: + cdef public int bar = 5 + cdef public object baz = u"someval" + +cdef class MyCyFoo(CyFoo): + cdef public int bar = 7 + cdef public object baz = u"anotherval" + +class AnotherFoo(CyFoo): + bar = 8 + baz = u"yetanotherval"