Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xavier Thompson
cython
Commits
31ee9cab
Commit
31ee9cab
authored
Feb 09, 2019
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend cpdef method test to cover some more (non-)override cases.
parent
d4bd468a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
1 deletion
+55
-1
tests/run/cpdef_method_override.pyx
tests/run/cpdef_method_override.pyx
+55
-1
No files found.
tests/run/cpdef_method_override.pyx
View file @
31ee9cab
...
@@ -31,12 +31,35 @@ cdef class BaseType:
...
@@ -31,12 +31,35 @@ cdef class BaseType:
BaseType.meth
BaseType.meth
BaseType.meth
BaseType.meth
"""
"""
def
callmeth
(
self
):
cpdef
callmeth
(
self
):
return
self
.
callmeth2
()
cpdef
callmeth2
(
self
):
# not overridden by subclasses
return
self
.
meth
()
return
self
.
meth
()
cpdef
meth
(
self
):
cpdef
meth
(
self
):
# overridden by subclasses
print
(
"BaseType.meth"
)
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
):
class
PyClass
(
BaseType
):
"""
"""
>>> PyClass().callmeth()
>>> PyClass().callmeth()
...
@@ -83,3 +106,34 @@ class PySlotsClass(BaseType):
...
@@ -83,3 +106,34 @@ class PySlotsClass(BaseType):
def
meth
(
self
):
def
meth
(
self
):
print
(
"PySlotsClass.meth"
)
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"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment