diff options
author | Armin Ronacher <armin.ronacher@active-4.com> | 2015-11-24 10:33:51 +0100 |
---|---|---|
committer | Armin Ronacher <armin.ronacher@active-4.com> | 2015-11-24 10:33:51 +0100 |
commit | 1c7e1d3f41c1d4d79a3fc0d3559f619ecc560388 (patch) | |
tree | 09f1e26e4110b590b37c75762c5f6efdadf69893 /tests/test_chain.py | |
parent | 07a4f18863de6dee39fd491276649661f03d6347 (diff) | |
download | click-1c7e1d3f41c1d4d79a3fc0d3559f619ecc560388.tar.gz |
Disallow arguments in chain mode and no longer expose leftover args.
Diffstat (limited to 'tests/test_chain.py')
-rw-r--r-- | tests/test_chain.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/test_chain.py b/tests/test_chain.py index 9f86a8f..aee6f2d 100644 --- a/tests/test_chain.py +++ b/tests/test_chain.py @@ -1,4 +1,6 @@ +import sys import click +import pytest def test_basic_chaining(runner): @@ -152,3 +154,44 @@ def test_pipeline(runner): 'FOO', 'BAR', ] + + +def test_args_and_chain(runner): + def debug(): + click.echo('%s=%s' % ( + sys._getframe(1).f_code.co_name, + '|'.join(click.get_current_context().args), + )) + + @click.group(chain=True) + def cli(): + debug() + + @cli.command() + def a(): + debug() + + @cli.command() + def b(): + debug() + + @cli.command() + def c(): + debug() + + result = runner.invoke(cli, ['a', 'b', 'c']) + assert not result.exception + assert result.output.splitlines() == [ + 'cli=', + 'a=', + 'b=', + 'c=', + ] + + +def test_multicommand_no_args(runner): + with pytest.raises(RuntimeError): + @click.group(chain=True) + @click.argument('forbidden') + def cli(): + pass |