diff options
author | David Lord <davidism@gmail.com> | 2021-10-10 10:54:41 -0700 |
---|---|---|
committer | David Lord <davidism@gmail.com> | 2021-10-10 10:59:02 -0700 |
commit | 662a30e4ee3fee7e92edc56a2cd03bbf3200dc4b (patch) | |
tree | 1a72eda0119de00d864ba865d38ebf4906f39b89 /tests/test_commands.py | |
parent | 3dde6c51c5015b7eba552348488c2f7bcaa16c69 (diff) | |
download | click-662a30e4ee3fee7e92edc56a2cd03bbf3200dc4b.tar.gz |
invoke type casts default values
Diffstat (limited to 'tests/test_commands.py')
-rw-r--r-- | tests/test_commands.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/tests/test_commands.py b/tests/test_commands.py index 9ebf612..788398c 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -246,15 +246,17 @@ def test_other_command_invoke_with_defaults(runner): return ctx.invoke(other_cmd) @click.command() - @click.option("--foo", type=click.INT, default=42) + @click.option("-a", type=click.INT, default=42) + @click.option("-b", type=click.INT, default="15") + @click.option("-c", multiple=True) @click.pass_context - def other_cmd(ctx, foo): - assert ctx.info_name == "other-cmd" - click.echo(foo) + def other_cmd(ctx, a, b, c): + return ctx.info_name, a, b, c - result = runner.invoke(cli, []) - assert not result.exception - assert result.output == "42\n" + result = runner.invoke(cli, standalone_mode=False) + # invoke should type cast default values, str becomes int, empty + # multiple should be empty tuple instead of None + assert result.return_value == ("other-cmd", 42, 15, ()) def test_invoked_subcommand(runner): |