diff options
author | John Reese <john@noswap.com> | 2022-04-05 12:57:19 -0700 |
---|---|---|
committer | David Lord <davidism@gmail.com> | 2022-04-28 06:51:25 -0700 |
commit | daa2d8e44332f66f09be83a9872218fde318bb8d (patch) | |
tree | e0b74bb01ddb36888e4abea73b62b0232862f11e /tests | |
parent | afdfb120fff5cb5f8d0184d411369f5dddaed5b3 (diff) | |
download | click-daa2d8e44332f66f09be83a9872218fde318bb8d.tar.gz |
disallow use of is_flag and multiple in option
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_options.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_options.py b/tests/test_options.py index 2e1f291..d4090c7 100644 --- a/tests/test_options.py +++ b/tests/test_options.py @@ -904,3 +904,21 @@ def test_type_from_flag_value(): ) def test_is_bool_flag_is_correctly_set(option, expected): assert option.is_bool_flag is expected + + +@pytest.mark.parametrize( + ("kwargs", "message"), + [ + ({"count": True, "multiple": True}, "'count' is not valid with 'multiple'."), + ({"count": True, "is_flag": True}, "'count' is not valid with 'is_flag'."), + ( + {"multiple": True, "is_flag": True}, + "'multiple' is not valid with 'is_flag', use 'count'.", + ), + ], +) +def test_invalid_flag_combinations(runner, kwargs, message): + with pytest.raises(TypeError) as e: + click.Option(["-a"], **kwargs) + + assert message in str(e.value) |