summaryrefslogtreecommitdiff
path: root/tests/test_arguments.py
diff options
context:
space:
mode:
authorArmin Ronacher <armin.ronacher@active-4.com>2015-11-24 18:29:27 +0100
committerArmin Ronacher <armin.ronacher@active-4.com>2015-11-24 18:29:27 +0100
commit5f98f570c08a11e607cccfd9c1b787c69a6a67b7 (patch)
tree20f813d64b5a86774017effd5093042d9f296702 /tests/test_arguments.py
parent0a2919f34fcbc635d8530b4c5b60bf119b2bcedb (diff)
downloadclick-5f98f570c08a11e607cccfd9c1b787c69a6a67b7.tar.gz
Implemented defaults for args with nargs > 1.
This fixes #463
Diffstat (limited to 'tests/test_arguments.py')
-rw-r--r--tests/test_arguments.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_arguments.py b/tests/test_arguments.py
index 570888c..751ca69 100644
--- a/tests/test_arguments.py
+++ b/tests/test_arguments.py
@@ -258,3 +258,21 @@ def test_nargs_specified_plus_star_ordering(runner):
'd',
PY2 and "(u'e', u'f')" or "('e', 'f')",
]
+
+
+def test_defaults_for_nargs(runner):
+ @click.command()
+ @click.argument('a', nargs=2, type=int, default=(1, 2))
+ def cmd(a):
+ x, y = a
+ click.echo(x + y)
+
+ result = runner.invoke(cmd, [])
+ assert result.output.strip() == '3'
+
+ result = runner.invoke(cmd, ['3', '4'])
+ assert result.output.strip() == '7'
+
+ result = runner.invoke(cmd, ['3'])
+ assert result.exception is not None
+ assert 'argument a takes 2 values' in result.output