diff options
author | Ivan Kapelyukhin <ikapelyukhin@opensuse.org> | 2021-07-13 21:49:39 +0200 |
---|---|---|
committer | David Lord <davidism@gmail.com> | 2021-10-08 14:41:00 -0700 |
commit | aa6f36017e5132836ea8679a4143a08944fa5c8c (patch) | |
tree | 6276b9a6a3ad8739fc35296ec7a5f6bad95bfbaf /tests | |
parent | 0905156e0f9b3bb1eabf50173982add053e23ddf (diff) | |
download | click-aa6f36017e5132836ea8679a4143a08944fa5c8c.tar.gz |
option with multiple and flag_value replaces internal placeholder
Co-authored-by: David Lord <davidism@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_options.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_options.py b/tests/test_options.py index 06a70b4..2e34337 100644 --- a/tests/test_options.py +++ b/tests/test_options.py @@ -792,6 +792,29 @@ def test_option_with_optional_value(runner, args, expect): assert result.return_value == expect +def test_multiple_option_with_optional_value(runner): + cli = click.Command( + "cli", + params=[ + click.Option(["-f"], is_flag=False, flag_value="flag", multiple=True), + click.Option(["-a"]), + click.Argument(["b"], nargs=-1), + ], + callback=lambda **kwargs: kwargs, + ) + result = runner.invoke( + cli, + ["-f", "-f", "other", "-f", "-a", "1", "a", "b"], + standalone_mode=False, + catch_exceptions=False, + ) + assert result.return_value == { + "f": ("flag", "other", "flag"), + "a": "1", + "b": ("a", "b"), + } + + def test_type_from_flag_value(): param = click.Option(["-a", "x"], default=True, flag_value=4) assert param.type is click.INT |