Skip to content
Myr

Added tests for choice type

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 4ed961d · Browse files · 1 file+16 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+16 added−0 removed

  • tests:+16 added−0 removed

1 file+16 added−0 removed

modified:tests/test_basic.py+16 added
185 unmodified lines
186 assert not result_in.exception187 assert result_in.output == ''188 assert not result_out.exception189 assert result_out.output == 'Hello World!\n\n'190191192def test_choice_option(runner):193 @click.command()194 @click.option('--method', type=click.Choice(['foo', 'bar', 'baz']))195 def cli(method):196 click.echo(method)197198 result = runner.invoke(cli, ['--method=foo'])199 assert not result.exception200 assert result.output == 'foo\n'201202 result = runner.invoke(cli, ['--method=meh'])203 assert result.exit_code == 2204 assert 'Invalid value for "--method": invalid choice: meh. ' \205 '(choose from foo, bar, baz)' in result.output