summaryrefslogtreecommitdiff
path: root/tests/run/starargs.pyx
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run/starargs.pyx')
-rw-r--r--tests/run/starargs.pyx24
1 files changed, 21 insertions, 3 deletions
diff --git a/tests/run/starargs.pyx b/tests/run/starargs.pyx
index 5e17faa47..7da9c6442 100644
--- a/tests/run/starargs.pyx
+++ b/tests/run/starargs.pyx
@@ -1,7 +1,6 @@
cdef sorteditems(d):
- l = list(d.items())
- l.sort()
- return tuple(l)
+ return tuple(sorted(d.items()))
+
def spam(x, y, z):
"""
@@ -79,6 +78,8 @@ def onlyt(*a):
>>> onlyt(1, a=2)
Traceback (most recent call last):
TypeError: onlyt() got an unexpected keyword argument 'a'
+ >>> test_no_copy_args(onlyt)
+ True
"""
return a
@@ -114,3 +115,20 @@ def tk(*a, **k):
(1, ('a', 1), ('b', 2))
"""
return a + sorteditems(k)
+
+def t_kwonly(*a, k):
+ """
+ >>> test_no_copy_args(t_kwonly, k=None)
+ True
+ """
+ return a
+
+
+def test_no_copy_args(func, **kw):
+ """
+ func is a function such that func(*args, **kw) returns args.
+ We test that no copy is made of the args tuple.
+ This tests both the caller side and the callee side.
+ """
+ args = (1, 2, 3)
+ return func(*args, **kw) is args