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
3970ba08
Commit
3970ba08
authored
Feb 06, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extended test for star args in extension functions
parent
416e4035
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
25 deletions
+87
-25
tests/run/extstarargs.pyx
tests/run/extstarargs.pyx
+87
-25
No files found.
tests/run/extstarargs.pyx
View file @
3970ba08
__doc__
=
"""
__doc__
=
"""
>>> s = Silly(1,2,3, 'test')
>>> s = Silly(1,2,3, 'test')
>>> (spam,grail,swallow,creosote,onlyt,onlyk,tk) = (
... s.spam,s.grail,s.swallow,s.creosote,s.onlyt,s.onlyk,s.tk)
>>> s.spam(1,2,3)
>>> spam(1,2,3)
>>> s.spam(1,2)
(1, 2, 3)
>>> spam(1,2)
Traceback (most recent call last):
Traceback (most recent call last):
TypeError: function takes exactly 3 arguments (2 given)
TypeError: function takes exactly 3 arguments (2 given)
>>> s
.s
pam(1,2,3,4)
>>> spam(1,2,3,4)
Traceback (most recent call last):
Traceback (most recent call last):
TypeError: function takes exactly 3 arguments (4 given)
TypeError: function takes exactly 3 arguments (4 given)
>>> s
.s
pam(1,2,3, a=1)
>>> spam(1,2,3, a=1)
Traceback (most recent call last):
Traceback (most recent call last):
TypeError: 'a' is an invalid keyword argument for this function
TypeError: 'a' is an invalid keyword argument for this function
>>> s.grail(1,2,3)
>>> grail(1,2,3)
>>> s.grail(1,2,3,4)
(1, 2, 3, ())
>>> s.grail(1,2,3,4,5,6,7,8,9)
>>> grail(1,2,3,4)
>>> s.grail(1,2)
(1, 2, 3, (4,))
>>> grail(1,2,3,4,5,6,7,8,9)
(1, 2, 3, (4, 5, 6, 7, 8, 9))
>>> grail(1,2)
Traceback (most recent call last):
Traceback (most recent call last):
TypeError: function takes exactly 3 arguments (2 given)
TypeError: function takes exactly 3 arguments (2 given)
>>>
s.
grail(1,2,3, a=1)
>>> grail(1,2,3, a=1)
Traceback (most recent call last):
Traceback (most recent call last):
TypeError: 'a' is an invalid keyword argument for this function
TypeError: 'a' is an invalid keyword argument for this function
>>> s.swallow(1,2,3)
>>> swallow(1,2,3)
>>> s.swallow(1,2,3,4)
(1, 2, 3, ())
>>> swallow(1,2,3,4)
Traceback (most recent call last):
Traceback (most recent call last):
TypeError: function takes at most 3 positional arguments (4 given)
TypeError: function takes at most 3 positional arguments (4 given)
>>> s.swallow(1,2,3, a=1, b=2)
>>> swallow(1,2,3, a=1, b=2)
>>> s.swallow(1,2,3, x=1)
(1, 2, 3, (('a', 1), ('b', 2)))
>>> swallow(1,2,3, x=1)
Traceback (most recent call last):
Traceback (most recent call last):
TypeError: keyword parameter 'x' was given by position and by name
TypeError: keyword parameter 'x' was given by position and by name
>>> s.creosote(1,2,3)
>>> creosote(1,2,3)
>>> s.creosote(1,2,3,4)
(1, 2, 3, (), ())
>>> s.creosote(1,2,3, a=1)
>>> creosote(1,2,3,4)
>>> s.creosote(1,2,3,4, a=1, b=2)
(1, 2, 3, (4,), ())
>>> s.creosote(1,2,3,4, x=1)
>>> creosote(1,2,3, a=1)
(1, 2, 3, (), (('a', 1),))
>>> creosote(1,2,3,4, a=1, b=2)
(1, 2, 3, (4,), (('a', 1), ('b', 2)))
>>> creosote(1,2,3,4, x=1)
Traceback (most recent call last):
Traceback (most recent call last):
TypeError: keyword parameter 'x' was given by position and by name
TypeError: keyword parameter 'x' was given by position and by name
>>> onlyt(1)
(1,)
>>> onlyt(1,2)
(1, 2)
>>> onlyt(a=1)
Traceback (most recent call last):
TypeError: 'a' is an invalid keyword argument for this function
>>> onlyt(1, a=2)
Traceback (most recent call last):
TypeError: 'a' is an invalid keyword argument for this function
>>> onlyk(a=1)
(('a', 1),)
>>> onlyk(a=1, b=2)
(('a', 1), ('b', 2))
>>> onlyk(1)
Traceback (most recent call last):
TypeError: function takes at most 0 positional arguments (1 given)
>>> onlyk(1, 2)
Traceback (most recent call last):
TypeError: function takes at most 0 positional arguments (2 given)
>>> onlyk(1, a=1, b=2)
Traceback (most recent call last):
TypeError: function takes at most 0 positional arguments (1 given)
>>> tk(a=1)
(('a', 1),)
>>> tk(a=1, b=2)
(('a', 1), ('b', 2))
>>> tk(1)
(1,)
>>> tk(1, 2)
(1, 2)
>>> tk(1, a=1, b=2)
(1, ('a', 1), ('b', 2))
"""
"""
cdef
sorteditems
(
d
):
l
=
d
.
items
()
l
.
sort
()
return
tuple
(
l
)
cdef
class
Silly
:
cdef
class
Silly
:
def
__init__
(
self
,
*
a
):
def
__init__
(
self
,
*
a
):
pass
pass
def
spam
(
self
,
x
,
y
,
z
):
def
spam
(
self
,
x
,
y
,
z
):
pass
return
(
x
,
y
,
z
)
def
grail
(
self
,
x
,
y
,
z
,
*
a
):
def
grail
(
self
,
x
,
y
,
z
,
*
a
):
pass
return
(
x
,
y
,
z
,
a
)
def
swallow
(
self
,
x
,
y
,
z
,
**
k
):
def
swallow
(
self
,
x
,
y
,
z
,
**
k
):
pass
return
(
x
,
y
,
z
,
sorteditems
(
k
))
def
creosote
(
self
,
x
,
y
,
z
,
*
a
,
**
k
):
def
creosote
(
self
,
x
,
y
,
z
,
*
a
,
**
k
):
pass
return
(
x
,
y
,
z
,
a
,
sorteditems
(
k
))
def
onlyt
(
self
,
*
a
):
return
a
def
onlyk
(
self
,
**
k
):
return
sorteditems
(
k
)
def
tk
(
self
,
*
a
,
**
k
):
return
a
+
sorteditems
(
k
)
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