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
Gwenaël Samain
cython
Commits
db36032e
Commit
db36032e
authored
Feb 12, 2012
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CyFunction's __defaults__ tests
parent
34864b14
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
tests/run/cyfunction_defaults.py
tests/run/cyfunction_defaults.py
+45
-0
No files found.
tests/run/cyfunction_defaults.py
0 → 100644
View file @
db36032e
# cython: binding=True
# mode: run
# tag: cyfunction
import
sys
def
get_defaults
(
func
):
"""
>>> get_defaults(get_defaults)
>>> hasattr(get_defaults, '__defaults__') and get_defaults.__defaults__
>>> hasattr(get_defaults, 'func_defaults') and get_defaults.func_defaults
"""
if
sys
.
version_info
>=
(
2
,
5
,
0
):
return
func
.
__defaults__
return
func
.
func_defaults
def
test_defaults_none
():
"""
>>> get_defaults(test_defaults_none)
"""
def
test_defaults_literal
(
a
=
1
,
b
=
[],
c
=
{}):
"""
>>> get_defaults(test_defaults_literal)
(1, [], {})
"""
def
test_defaults_nonliteral
():
"""
>>> f0, f1 = test_defaults_nonliteral()
>>> get_defaults(f0) is get_defaults(f0) # cached
True
>>> get_defaults(f0)
(0, {})
>>> get_defaults(f1) is get_defaults(f1) # cached
True
>>> get_defaults(f1)
(0, [])
"""
ret
=
[]
for
i
in
{},
[]:
def
foo
(
a
,
b
=
0
,
c
=
i
):
pass
ret
.
append
(
foo
)
return
ret
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