diff options
author | Armin Ronacher <armin.ronacher@active-4.com> | 2014-09-09 15:00:34 +0200 |
---|---|---|
committer | Armin Ronacher <armin.ronacher@active-4.com> | 2014-09-09 15:00:34 +0200 |
commit | da0132f90068b5b7457bd8d8c363da0765412c1b (patch) | |
tree | 3a6150ee1bdb68350468052b670a62ff8034e036 /tests/test_commands.py | |
parent | f23951150a92a1c8461774abf30d543b3386f8d6 (diff) | |
download | click-da0132f90068b5b7457bd8d8c363da0765412c1b.tar.gz |
Added a test for ignoring of unknown options.
Diffstat (limited to 'tests/test_commands.py')
-rw-r--r-- | tests/test_commands.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_commands.py b/tests/test_commands.py index 7c8b453..ac9760f 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -252,3 +252,21 @@ def test_invoked_subcommand(runner): result = runner.invoke(cli) assert not result.exception assert result.output == 'no subcommand, use default\nin subcommand\n' + + +def test_unprocessed_options(runner): + @click.command(context_settings=dict( + ignore_unknown_options=True + )) + @click.argument('args', nargs=-1, type=click.UNPROCESSED) + @click.option('--verbose', '-v', count=True) + def cli(verbose, args): + click.echo('Verbosity: %s' % verbose) + click.echo('Args: %s' % '|'.join(args)) + + result = runner.invoke(cli, ['-foo', '-vvvvx', '--muhaha', 'x', 'y', '-x']) + assert not result.exception + assert result.output.splitlines() == [ + 'Verbosity: 4', + 'Args: -foo|-x|--muhaha|x|y|-x', + ] |