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
Boxiang Sun
cython
Commits
de8c251d
Commit
de8c251d
authored
Jul 13, 2014
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests for py2 style super().
parent
60dda57d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
0 deletions
+97
-0
tests/run/py2_super.pyx
tests/run/py2_super.pyx
+97
-0
No files found.
tests/run/py2_super.pyx
0 → 100644
View file @
de8c251d
# mode: run
# tag: py3k_super
class
A
(
object
):
def
method
(
self
):
return
1
@
classmethod
def
class_method
(
cls
):
return
2
@
staticmethod
def
static_method
():
return
3
def
generator_test
(
self
):
return
[
1
,
2
,
3
]
class
B
(
A
):
"""
>>> obj = B()
>>> obj.method()
1
>>> B.class_method()
2
>>> B.static_method(obj)
3
>>> list(obj.generator_test())
[1, 2, 3]
"""
def
method
(
self
):
return
super
(
B
,
self
).
method
()
@
classmethod
def
class_method
(
cls
):
return
super
(
B
,
cls
).
class_method
()
@
staticmethod
def
static_method
(
instance
):
return
super
(
B
,
instance
).
static_method
()
def
generator_test
(
self
):
for
i
in
super
(
B
,
self
).
generator_test
():
yield
i
cdef
class
CClassBase
(
object
):
def
method
(
self
):
return
'def'
cpdef
method_cp
(
self
):
return
'cpdef'
# cdef method_c(self):
# return 'cdef'
# def call_method_c(self):
# return self.method_c()
cdef
class
CClassSub
(
CClassBase
):
"""
>>> CClassSub().method()
'def'
>>> CClassSub().method_cp()
'cpdef'
"""
# >>> CClassSub().call_method_c()
# 'cdef'
def
method
(
self
):
return
super
(
CClassSub
,
self
).
method
()
cpdef
method_cp
(
self
):
return
super
(
CClassSub
,
self
).
method_cp
()
# cdef method_c(self):
# return super(CClassSub, self).method_c()
cdef
class
Base
(
object
):
"""
>>> Base().method()
'Base'
>>> Base.method(Base())
'Base'
"""
cpdef
method
(
self
):
return
"Base"
cdef
class
Sub
(
Base
):
"""
>>> Sub().method()
'Sub'
>>> Sub.method(Sub())
'Sub'
>>> Base.method(Sub())
'Base'
"""
cpdef
method
(
self
):
return
"Sub"
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