summaryrefslogtreecommitdiff
path: root/tests/basics/fun_kwonlydef.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-07-05 06:14:29 +0100
committerDamien George <damien.p.george@gmail.com>2014-07-05 06:14:29 +0100
commit539681fffd96082ca3b5d18643d4f08f65c47170 (patch)
tree7e6f8332c6e7737b768750e67265bb02b22932e6 /tests/basics/fun_kwonlydef.py
parent0182385ab0b4a1b2e549c92f8f5b621135aeb975 (diff)
tests: Rename test scripts, changing - to _ for consistency.
From now on, all new tests must use underscore. Addresses issue #727.
Diffstat (limited to 'tests/basics/fun_kwonlydef.py')
-rw-r--r--tests/basics/fun_kwonlydef.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/basics/fun_kwonlydef.py b/tests/basics/fun_kwonlydef.py
new file mode 100644
index 000000000..56a08ee81
--- /dev/null
+++ b/tests/basics/fun_kwonlydef.py
@@ -0,0 +1,36 @@
+# test function args, keyword only with default value
+
+# a single arg with a default
+def f1(*, a=1):
+ print(a)
+f1()
+f1(a=2)
+
+# 1 arg default, 1 not
+def f2(*, a=1, b):
+ print(a, b)
+f2(b=2)
+f2(a=2, b=3)
+
+# 1 positional, 1 arg default, 1 not
+def f3(a, *, b=2, c):
+ print(a, b, c)
+f3(1, c=3)
+f3(1, b=3, c=4)
+f3(1, **{'c':3})
+f3(1, **{'b':'3', 'c':4})
+
+# many args, not all with defaults
+def f4(*, a=1, b, c=3, d, e=5, f):
+ print(a, b, c, d, e, f)
+f4(b=2, d=4, f=6)
+f4(a=11, b=2, d=4, f=6)
+f4(a=11, b=2, c=33, d=4, e=55, f=6)
+f4(f=6, e=55, d=4, c=33, b=2, a=11)
+
+# positional with default, then keyword only
+def f5(a, b=4, *c, d=8):
+ print(a, b, c, d)
+f5(1)
+f5(1, d=9)
+f5(1, b=44, d=9)