diff options
author | Armin Ronacher <armin.ronacher@active-4.com> | 2015-11-24 10:42:09 +0100 |
---|---|---|
committer | Armin Ronacher <armin.ronacher@active-4.com> | 2015-11-24 10:42:41 +0100 |
commit | e68766c35ab134af2db2abf7cbd6f31e9b25d150 (patch) | |
tree | 473f57b194eb4189a27dc385aed7a54ede4d9c44 /tests/test_chain.py | |
parent | 1c7e1d3f41c1d4d79a3fc0d3559f619ecc560388 (diff) | |
download | click-e68766c35ab134af2db2abf7cbd6f31e9b25d150.tar.gz |
Support non optional arguments on commands.
This relaxes the restriction from the last commit to allow
required arguments with command groups again.
Diffstat (limited to 'tests/test_chain.py')
-rw-r--r-- | tests/test_chain.py | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/tests/test_chain.py b/tests/test_chain.py index aee6f2d..b76b114 100644 --- a/tests/test_chain.py +++ b/tests/test_chain.py @@ -189,9 +189,31 @@ def test_args_and_chain(runner): ] -def test_multicommand_no_args(runner): +def test_multicommand_arg_behavior(runner): with pytest.raises(RuntimeError): @click.group(chain=True) - @click.argument('forbidden') - def cli(): + @click.argument('forbidden', required=False) + def bad_cli(): pass + + with pytest.raises(RuntimeError): + @click.group(chain=True) + @click.argument('forbidden', nargs=-1) + def bad_cli2(): + pass + + @click.group(chain=True) + @click.argument('arg') + def cli(arg): + click.echo('cli:%s' % arg) + + @cli.command() + def a(): + click.echo('a') + + result = runner.invoke(cli, ['foo', 'a']) + assert not result.exception + assert result.output.splitlines() == [ + 'cli:foo', + 'a', + ] |