Commit 31ee9cab authored by Stefan Behnel's avatar Stefan Behnel

Extend cpdef method test to cover some more (non-)override cases.

parent d4bd468a
......@@ -31,12 +31,35 @@ cdef class BaseType:
BaseType.meth
BaseType.meth
"""
def callmeth(self):
cpdef callmeth(self):
return self.callmeth2()
cpdef callmeth2(self):
# not overridden by subclasses
return self.meth()
cpdef meth(self):
# overridden by subclasses
print("BaseType.meth")
class NonOverride(BaseType):
"""
>>> NonOverride().callmeth()
BaseType.meth
>>> obj = NonOverride()
>>> obj.callmeth()
BaseType.meth
>>> obj.callmeth()
BaseType.meth
>>> _call_method(NonOverride)
BaseType.meth
BaseType.meth
BaseType.meth
BaseType.meth
BaseType.meth
BaseType.meth
"""
class PyClass(BaseType):
"""
>>> PyClass().callmeth()
......@@ -83,3 +106,34 @@ class PySlotsClass(BaseType):
def meth(self):
print("PySlotsClass.meth")
class DynamicOverride(BaseType):
"""
>>> DynamicOverride().callmeth()
meth1
>>> obj = DynamicOverride()
>>> obj.callmeth()
meth1
>>> obj.callmeth()
meth2
>>> obj.callmeth()
BaseType.meth
>>> obj.callmeth()
BaseType.meth
>>> _call_method(DynamicOverride)
meth1
meth1
meth2
meth1
meth2
BaseType.meth
"""
def __init__(self):
self.meth = self.meth1
def meth1(self):
self.meth = self.meth2
print("meth1")
def meth2(self):
del self.meth
print("meth2")
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