summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2022-02-20 11:33:31 -0800
committerGitHub <noreply@github.com>2022-02-20 11:33:31 -0800
commit4262661a0fffabe3803f1bd876b19244f587dafa (patch)
treec0550260fe4a4e1f8229638425bd6221dec676b3 /tests
parent422cb2064eed146dbe03ba3aed5be35daeb70414 (diff)
parent40830087dd9e9023dbcf75befe0ca9056127a064 (diff)
downloadclick-4262661a0fffabe3803f1bd876b19244f587dafa.tar.gz
Merge pull request #1990 from dannysepler/dsepler/enforce-required-flag
Enforce required flag
Diffstat (limited to 'tests')
-rw-r--r--tests/test_options.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/test_options.py b/tests/test_options.py
index ab230c4..3beff11 100644
--- a/tests/test_options.py
+++ b/tests/test_options.py
@@ -502,6 +502,15 @@ def test_missing_option_string_cast():
assert str(excinfo.value) == "Missing parameter: a"
+def test_missing_required_flag(runner):
+ cli = click.Command(
+ "cli", params=[click.Option(["--on/--off"], is_flag=True, required=True)]
+ )
+ result = runner.invoke(cli)
+ assert result.exit_code == 2
+ assert "Error: Missing option '--on'." in result.output
+
+
def test_missing_choice(runner):
@click.command()
@click.option("--foo", type=click.Choice(["foo", "bar"]), required=True)