test_options.py
This file
Path
tests/test_options.py
803 lines · 24.4 KiB · Python
Last changed by
Merge pull request #2084 from pallets/count-type-helpDavid Lordbefore adoptionf74dbbb
History of this fileTake it
1import os2import re34import pytest56import click7from click import Option8910def test_prefixes(runner):11 @click.command()12 @click.option("++foo", is_flag=True, help="das foo")13 @click.option("--bar", is_flag=True, help="das bar")14 def cli(foo, bar):15 click.echo(f"foo={foo} bar={bar}")1617 result = runner.invoke(cli, ["++foo", "--bar"])18 assert not result.exception19 assert result.output == "foo=True bar=True\n"2021 result = runner.invoke(cli, ["--help"])22 assert re.search(r"\+\+foo\s+das foo", result.output) is not None23 assert re.search(r"--bar\s+das bar", result.output) is not None242526def test_invalid_option(runner):27 with pytest.raises(TypeError, match="name was passed") as exc_info:28 click.Option(["foo"])2930 message = str(exc_info.value)31 assert "name was passed (foo)" in message32 assert "declare an argument" in message33 assert "'--foo'" in message343536def test_invalid_nargs(runner):37 with pytest.raises(TypeError, match="nargs=-1"):3839 @click.command()40 @click.option("--foo", nargs=-1)41 def cli(foo):42 pass434445def test_nargs_tup_composite_mult(runner):46 @click.command()47 @click.option("--item", type=(str, int), multiple=True)48 def copy(item):49 for name, id in item:50 click.echo(f"name={name} id={id:d}")5152 result = runner.invoke(copy, ["--item", "peter", "1", "--item", "max", "2"])53 assert not result.exception54 assert result.output.splitlines() == ["name=peter id=1", "name=max id=2"]555657def test_counting(runner):58 @click.command()59 @click.option("-v", count=True, help="Verbosity", type=click.IntRange(0, 3))60 def cli(v):61 click.echo(f"verbosity={v:d}")6263 result = runner.invoke(cli, ["-vvv"])64 assert not result.exception65 assert result.output == "verbosity=3\n"6667 result = runner.invoke(cli, ["-vvvv"])68 assert result.exception69 assert "Invalid value for '-v': 4 is not in the range 0<=x<=3." in result.output7071 result = runner.invoke(cli, [])72 assert not result.exception73 assert result.output == "verbosity=0\n"7475 result = runner.invoke(cli, ["--help"])76 assert re.search(r"-v\s+Verbosity", result.output) is not None777879@pytest.mark.parametrize("unknown_flag", ["--foo", "-f"])80def test_unknown_options(runner, unknown_flag):81 @click.command()82 def cli():83 pass8485 result = runner.invoke(cli, [unknown_flag])86 assert result.exception87 assert f"No such option: {unknown_flag}" in result.output888990@pytest.mark.parametrize(91 ("value", "expect"),92 [93 ("--cat", "Did you mean --count?"),94 ("--bounds", "(Possible options: --bound, --count)"),95 ("--bount", "(Possible options: --bound, --count)"),96 ],97)98def test_suggest_possible_options(runner, value, expect):99 cli = click.Command(100 "cli", params=[click.Option(["--bound"]), click.Option(["--count"])]101 )102 result = runner.invoke(cli, [value])103 assert expect in result.output104105106def test_multiple_required(runner):107 @click.command()108 @click.option("-m", "--message", multiple=True, required=True)109 def cli(message):110 click.echo("\n".join(message))111112 result = runner.invoke(cli, ["-m", "foo", "-mbar"])113 assert not result.exception114 assert result.output == "foo\nbar\n"115116 result = runner.invoke(cli, [])117 assert result.exception118 assert "Error: Missing option '-m' / '--message'." in result.output119120121@pytest.mark.parametrize(122 ("multiple", "nargs", "default"),123 [124 (True, 1, []),125 (True, 1, [1]),126 # (False, -1, []),127 # (False, -1, [1]),128 (False, 2, [1, 2]),129 # (True, -1, [[]]),130 # (True, -1, []),131 # (True, -1, [[1]]),132 (True, 2, []),133 (True, 2, [[1, 2]]),134 ],135)136def test_init_good_default_list(runner, multiple, nargs, default):137 click.Option(["-a"], multiple=multiple, nargs=nargs, default=default)138139140@pytest.mark.parametrize(141 ("multiple", "nargs", "default"),142 [143 (True, 1, 1),144 # (False, -1, 1),145 (False, 2, [1]),146 (True, 2, [[1]]),147 ],148)149def test_init_bad_default_list(runner, multiple, nargs, default):150 type = (str, str) if nargs == 2 else None151152 with pytest.raises(ValueError, match="default"):153 click.Option(["-a"], type=type, multiple=multiple, nargs=nargs, default=default)154155156def test_empty_envvar(runner):157 @click.command()158 @click.option("--mypath", type=click.Path(exists=True), envvar="MYPATH")159 def cli(mypath):160 click.echo(f"mypath: {mypath}")161162 result = runner.invoke(cli, [], env={"MYPATH": ""})163 assert result.exit_code == 0164 assert result.output == "mypath: None\n"165166167def test_multiple_envvar(runner):168 @click.command()169 @click.option("--arg", multiple=True)170 def cmd(arg):171 click.echo("|".join(arg))172173 result = runner.invoke(174 cmd, [], auto_envvar_prefix="TEST", env={"TEST_ARG": "foo bar baz"}175 )176 assert not result.exception177 assert result.output == "foo|bar|baz\n"178179 @click.command()180 @click.option("--arg", multiple=True, envvar="X")181 def cmd(arg):182 click.echo("|".join(arg))183184 result = runner.invoke(cmd, [], env={"X": "foo bar baz"})185 assert not result.exception186 assert result.output == "foo|bar|baz\n"187188 @click.command()189 @click.option("--arg", multiple=True, type=click.Path())190 def cmd(arg):191 click.echo("|".join(arg))192193 result = runner.invoke(194 cmd,195 [],196 auto_envvar_prefix="TEST",197 env={"TEST_ARG": f"foo{os.path.pathsep}bar"},198 )199 assert not result.exception200 assert result.output == "foo|bar\n"201202203def test_trailing_blanks_boolean_envvar(runner):204 @click.command()205 @click.option("--shout/--no-shout", envvar="SHOUT")206 def cli(shout):207 click.echo(f"shout: {shout!r}")208209 result = runner.invoke(cli, [], env={"SHOUT": " true "})210 assert result.exit_code == 0211 assert result.output == "shout: True\n"212213214def test_multiple_default_help(runner):215 @click.command()216 @click.option("--arg1", multiple=True, default=("foo", "bar"), show_default=True)217 @click.option("--arg2", multiple=True, default=(1, 2), type=int, show_default=True)218 def cmd(arg, arg2):219 pass220221 result = runner.invoke(cmd, ["--help"])222 assert not result.exception223 assert "foo, bar" in result.output224 assert "1, 2" in result.output225226227def test_show_default_default_map(runner):228 @click.command()229 @click.option("--arg", default="a", show_default=True)230 def cmd(arg):231 click.echo(arg)232233 result = runner.invoke(cmd, ["--help"], default_map={"arg": "b"})234235 assert not result.exception236 assert "[default: b]" in result.output237238239def test_multiple_default_type():240 opt = click.Option(["-a"], multiple=True, default=(1, 2))241 assert opt.nargs == 1242 assert opt.multiple243 assert opt.type is click.INT244 ctx = click.Context(click.Command("test"))245 assert opt.get_default(ctx) == (1, 2)246247248def test_multiple_default_composite_type():249 opt = click.Option(["-a"], multiple=True, default=[(1, "a")])250 assert opt.nargs == 2251 assert opt.multiple252 assert isinstance(opt.type, click.Tuple)253 assert opt.type.types == [click.INT, click.STRING]254 ctx = click.Context(click.Command("test"))255 assert opt.get_default(ctx) == ((1, "a"),)256257258def test_parse_multiple_default_composite_type(runner):259 @click.command()260 @click.option("-a", multiple=True, default=("a", "b"))261 @click.option("-b", multiple=True, default=[(1, "a")])262 def cmd(a, b):263 click.echo(a)264 click.echo(b)265266 # result = runner.invoke(cmd, "-a c -a 1 -a d -b 2 two -b 4 four".split())267 # assert result.output == "('c', '1', 'd')\n((2, 'two'), (4, 'four'))\n"268 result = runner.invoke(cmd)269 assert result.output == "('a', 'b')\n((1, 'a'),)\n"270271272def test_dynamic_default_help_unset(runner):273 @click.command()274 @click.option(275 "--username",276 prompt=True,277 default=lambda: os.environ.get("USER", ""),278 show_default=True,279 )280 def cmd(username):281 print("Hello,", username)282283 result = runner.invoke(cmd, ["--help"])284 assert result.exit_code == 0285 assert "--username" in result.output286 assert "lambda" not in result.output287 assert "(dynamic)" in result.output288289290def test_dynamic_default_help_text(runner):291 @click.command()292 @click.option(293 "--username",294 prompt=True,295 default=lambda: os.environ.get("USER", ""),296 show_default="current user",297 )298 def cmd(username):299 print("Hello,", username)300301 result = runner.invoke(cmd, ["--help"])302 assert result.exit_code == 0303 assert "--username" in result.output304 assert "lambda" not in result.output305 assert "(current user)" in result.output306307308@pytest.mark.parametrize(309 ("type", "expect"),310 [311 (click.IntRange(1, 32), "1<=x<=32"),312 (click.IntRange(1, 32, min_open=True, max_open=True), "1<x<32"),313 (click.IntRange(1), "x>=1"),314 (click.IntRange(max=32), "x<=32"),315 ],316)317def test_intrange_default_help_text(type, expect):318 option = click.Option(["--num"], type=type, show_default=True, default=2)319 context = click.Context(click.Command("test"))320 result = option.get_help_record(context)[1]321 assert expect in result322323324def test_count_default_type_help():325 """A count option with the default type should not show >=0 in help."""326 option = click.Option(["--couunt"], count=True, help="some words")327 context = click.Context(click.Command("test"))328 result = option.get_help_record(context)[1]329 assert result == "some words"330331332def test_toupper_envvar_prefix(runner):333 @click.command()334 @click.option("--arg")335 def cmd(arg):336 click.echo(arg)337338 result = runner.invoke(cmd, [], auto_envvar_prefix="test", env={"TEST_ARG": "foo"})339 assert not result.exception340 assert result.output == "foo\n"341342343def test_nargs_envvar(runner):344 @click.command()345 @click.option("--arg", nargs=2)346 def cmd(arg):347 click.echo("|".join(arg))348349 result = runner.invoke(350 cmd, [], auto_envvar_prefix="TEST", env={"TEST_ARG": "foo bar"}351 )352 assert not result.exception353 assert result.output == "foo|bar\n"354355 @click.command()356 @click.option("--arg", nargs=2, multiple=True)357 def cmd(arg):358 for item in arg:359 click.echo("|".join(item))360361 result = runner.invoke(362 cmd, [], auto_envvar_prefix="TEST", env={"TEST_ARG": "x 1 y 2"}363 )364 assert not result.exception365 assert result.output == "x|1\ny|2\n"366367368def test_show_envvar(runner):369 @click.command()370 @click.option("--arg1", envvar="ARG1", show_envvar=True)371 def cmd(arg):372 pass373374 result = runner.invoke(cmd, ["--help"])375 assert not result.exception376 assert "ARG1" in result.output377378379def test_show_envvar_auto_prefix(runner):380 @click.command()381 @click.option("--arg1", show_envvar=True)382 def cmd(arg):383 pass384385 result = runner.invoke(cmd, ["--help"], auto_envvar_prefix="TEST")386 assert not result.exception387 assert "TEST_ARG1" in result.output388389390def test_show_envvar_auto_prefix_dash_in_command(runner):391 @click.group()392 def cli():393 pass394395 @cli.command()396 @click.option("--baz", show_envvar=True)397 def foo_bar(baz):398 pass399400 result = runner.invoke(cli, ["foo-bar", "--help"], auto_envvar_prefix="TEST")401 assert not result.exception402 assert "TEST_FOO_BAR_BAZ" in result.output403404405def test_custom_validation(runner):406 def validate_pos_int(ctx, param, value):407 if value < 0:408 raise click.BadParameter("Value needs to be positive")409 return value410411 @click.command()412 @click.option("--foo", callback=validate_pos_int, default=1)413 def cmd(foo):414 click.echo(foo)415416 result = runner.invoke(cmd, ["--foo", "-1"])417 assert "Invalid value for '--foo': Value needs to be positive" in result.output418419 result = runner.invoke(cmd, ["--foo", "42"])420 assert result.output == "42\n"421422423def test_callback_validates_prompt(runner, monkeypatch):424 def validate(ctx, param, value):425 if value < 0:426 raise click.BadParameter("should be positive")427428 return value429430 @click.command()431 @click.option("-a", type=int, callback=validate, prompt=True)432 def cli(a):433 click.echo(a)434435 result = runner.invoke(cli, input="-12\n60\n")436 assert result.output == "A: -12\nError: should be positive\nA: 60\n60\n"437438439def test_winstyle_options(runner):440 @click.command()441 @click.option("/debug;/no-debug", help="Enables or disables debug mode.")442 def cmd(debug):443 click.echo(debug)444445 result = runner.invoke(cmd, ["/debug"], help_option_names=["/?"])446 assert result.output == "True\n"447 result = runner.invoke(cmd, ["/no-debug"], help_option_names=["/?"])448 assert result.output == "False\n"449 result = runner.invoke(cmd, [], help_option_names=["/?"])450 assert result.output == "False\n"451 result = runner.invoke(cmd, ["/?"], help_option_names=["/?"])452 assert "/debug; /no-debug Enables or disables debug mode." in result.output453 assert "/? Show this message and exit." in result.output454455456def test_legacy_options(runner):457 @click.command()458 @click.option("-whatever")459 def cmd(whatever):460 click.echo(whatever)461462 result = runner.invoke(cmd, ["-whatever", "42"])463 assert result.output == "42\n"464 result = runner.invoke(cmd, ["-whatever=23"])465 assert result.output == "23\n"466467468def test_missing_option_string_cast():469 ctx = click.Context(click.Command(""))470471 with pytest.raises(click.MissingParameter) as excinfo:472 click.Option(["-a"], required=True).process_value(ctx, None)473474 assert str(excinfo.value) == "Missing parameter: a"475476477def test_missing_choice(runner):478 @click.command()479 @click.option("--foo", type=click.Choice(["foo", "bar"]), required=True)480 def cmd(foo):481 click.echo(foo)482483 result = runner.invoke(cmd)484 assert result.exit_code == 2485 error, separator, choices = result.output.partition("Choose from")486 assert "Error: Missing option '--foo'. " in error487 assert "Choose from" in separator488 assert "foo" in choices489 assert "bar" in choices490491492def test_case_insensitive_choice(runner):493 @click.command()494 @click.option("--foo", type=click.Choice(["Orange", "Apple"], case_sensitive=False))495 def cmd(foo):496 click.echo(foo)497498 result = runner.invoke(cmd, ["--foo", "apple"])499 assert result.exit_code == 0500 assert result.output == "Apple\n"501502 result = runner.invoke(cmd, ["--foo", "oRANGe"])503 assert result.exit_code == 0504 assert result.output == "Orange\n"505506 result = runner.invoke(cmd, ["--foo", "Apple"])507 assert result.exit_code == 0508 assert result.output == "Apple\n"509510 @click.command()511 @click.option("--foo", type=click.Choice(["Orange", "Apple"]))512 def cmd2(foo):513 click.echo(foo)514515 result = runner.invoke(cmd2, ["--foo", "apple"])516 assert result.exit_code == 2517518 result = runner.invoke(cmd2, ["--foo", "oRANGe"])519 assert result.exit_code == 2520521 result = runner.invoke(cmd2, ["--foo", "Apple"])522 assert result.exit_code == 0523524525def test_case_insensitive_choice_returned_exactly(runner):526 @click.command()527 @click.option("--foo", type=click.Choice(["Orange", "Apple"], case_sensitive=False))528 def cmd(foo):529 click.echo(foo)530531 result = runner.invoke(cmd, ["--foo", "apple"])532 assert result.exit_code == 0533 assert result.output == "Apple\n"534535536def test_option_help_preserve_paragraphs(runner):537 @click.command()538 @click.option(539 "-C",540 "--config",541 type=click.Path(),542 help="""Configuration file to use.543544 If not given, the environment variable CONFIG_FILE is consulted545 and used if set. If neither are given, a default configuration546 file is loaded.""",547 )548 def cmd(config):549 pass550551 result = runner.invoke(cmd, ["--help"])552 assert result.exit_code == 0553 i = " " * 21554 assert (555 " -C, --config PATH Configuration file to use.\n"556 f"{i}\n"557 f"{i}If not given, the environment variable CONFIG_FILE is\n"558 f"{i}consulted and used if set. If neither are given, a default\n"559 f"{i}configuration file is loaded."560 ) in result.output561562563def test_argument_custom_class(runner):564 class CustomArgument(click.Argument):565 def get_default(self, ctx, call=True):566 """a dumb override of a default value for testing"""567 return "I am a default"568569 @click.command()570 @click.argument("testarg", cls=CustomArgument, default="you wont see me")571 def cmd(testarg):572 click.echo(testarg)573574 result = runner.invoke(cmd)575 assert "I am a default" in result.output576 assert "you wont see me" not in result.output577578579def test_option_custom_class(runner):580 class CustomOption(click.Option):581 def get_help_record(self, ctx):582 """a dumb override of a help text for testing"""583 return ("--help", "I am a help text")584585 @click.command()586 @click.option("--testoption", cls=CustomOption, help="you wont see me")587 def cmd(testoption):588 click.echo(testoption)589590 result = runner.invoke(cmd, ["--help"])591 assert "I am a help text" in result.output592 assert "you wont see me" not in result.output593594595def test_option_custom_class_reusable(runner):596 """Ensure we can reuse a custom class option. See Issue #926"""597598 class CustomOption(click.Option):599 def get_help_record(self, ctx):600 """a dumb override of a help text for testing"""601 return ("--help", "I am a help text")602603 # Assign to a variable to re-use the decorator.604 testoption = click.option("--testoption", cls=CustomOption, help="you wont see me")605606 @click.command()607 @testoption608 def cmd1(testoption):609 click.echo(testoption)610611 @click.command()612 @testoption613 def cmd2(testoption):614 click.echo(testoption)615616 # Both of the commands should have the --help option now.617 for cmd in (cmd1, cmd2):618619 result = runner.invoke(cmd, ["--help"])620 assert "I am a help text" in result.output621 assert "you wont see me" not in result.output622623624def test_bool_flag_with_type(runner):625 @click.command()626 @click.option("--shout/--no-shout", default=False, type=bool)627 def cmd(shout):628 pass629630 result = runner.invoke(cmd)631 assert not result.exception632633634def test_aliases_for_flags(runner):635 @click.command()636 @click.option("--warnings/--no-warnings", " /-W", default=True)637 def cli(warnings):638 click.echo(warnings)639640 result = runner.invoke(cli, ["--warnings"])641 assert result.output == "True\n"642 result = runner.invoke(cli, ["--no-warnings"])643 assert result.output == "False\n"644 result = runner.invoke(cli, ["-W"])645 assert result.output == "False\n"646647 @click.command()648 @click.option("--warnings/--no-warnings", "-w", default=True)649 def cli_alt(warnings):650 click.echo(warnings)651652 result = runner.invoke(cli_alt, ["--warnings"])653 assert result.output == "True\n"654 result = runner.invoke(cli_alt, ["--no-warnings"])655 assert result.output == "False\n"656 result = runner.invoke(cli_alt, ["-w"])657 assert result.output == "True\n"658659660@pytest.mark.parametrize(661 "option_args,expected",662 [663 (["--aggressive", "--all", "-a"], "aggressive"),664 (["--first", "--second", "--third", "-a", "-b", "-c"], "first"),665 (["--apple", "--banana", "--cantaloupe", "-a", "-b", "-c"], "apple"),666 (["--cantaloupe", "--banana", "--apple", "-c", "-b", "-a"], "cantaloupe"),667 (["-a", "-b", "-c"], "a"),668 (["-c", "-b", "-a"], "c"),669 (["-a", "--apple", "-b", "--banana", "-c", "--cantaloupe"], "apple"),670 (["-c", "-a", "--cantaloupe", "-b", "--banana", "--apple"], "cantaloupe"),671 (["--from", "-f", "_from"], "_from"),672 (["--return", "-r", "_ret"], "_ret"),673 ],674)675def test_option_names(runner, option_args, expected):676 @click.command()677 @click.option(*option_args, is_flag=True)678 def cmd(**kwargs):679 click.echo(str(kwargs[expected]))680681 assert cmd.params[0].name == expected682683 for form in option_args:684 if form.startswith("-"):685 result = runner.invoke(cmd, [form])686 assert result.output == "True\n"687688689def test_flag_duplicate_names(runner):690 with pytest.raises(ValueError, match="cannot use the same flag for true/false"):691 click.Option(["--foo/--foo"], default=False)692693694@pytest.mark.parametrize(("default", "expect"), [(False, "no-cache"), (True, "cache")])695def test_show_default_boolean_flag_name(runner, default, expect):696 """When a boolean flag has distinct True/False opts, it should show697 the default opt name instead of the default value. It should only698 show one name even if multiple are declared.699 """700 opt = click.Option(701 ("--cache/--no-cache", "--c/--nc"),702 default=default,703 show_default=True,704 help="Enable/Disable the cache.",705 )706 ctx = click.Context(click.Command("test"))707 message = opt.get_help_record(ctx)[1]708 assert f"[default: {expect}]" in message709710711def test_show_default_boolean_flag_value(runner):712 """When a boolean flag only has one opt, it will show the default713 value, not the opt name.714 """715 opt = click.Option(716 ("--cache",), is_flag=True, show_default=True, help="Enable the cache."717 )718 ctx = click.Context(click.Command("test"))719 message = opt.get_help_record(ctx)[1]720 assert "[default: False]" in message721722723def test_show_default_string(runner):724 """When show_default is a string show that value as default."""725 opt = click.Option(["--limit"], show_default="unlimited")726 ctx = click.Context(click.Command("cli"))727 message = opt.get_help_record(ctx)[1]728 assert "[default: (unlimited)]" in message729730731def test_do_not_show_no_default(runner):732 """When show_default is True and no default is set do not show None."""733 opt = click.Option(["--limit"], show_default=True)734 ctx = click.Context(click.Command("cli"))735 message = opt.get_help_record(ctx)[1]736 assert "[default: None]" not in message737738739def test_do_not_show_default_empty_multiple():740 """When show_default is True and multiple=True is set, it should not741 print empty default value in --help output.742 """743 opt = click.Option(["-a"], multiple=True, help="values", show_default=True)744 ctx = click.Context(click.Command("cli"))745 message = opt.get_help_record(ctx)[1]746 assert message == "values"747748749@pytest.mark.parametrize(750 ("args", "expect"),751 [752 (None, (None, None, ())),753 (["--opt"], ("flag", None, ())),754 (["--opt", "-a", 42], ("flag", "42", ())),755 (["--opt", "test", "-a", 42], ("test", "42", ())),756 (["--opt=test", "-a", 42], ("test", "42", ())),757 (["-o"], ("flag", None, ())),758 (["-o", "-a", 42], ("flag", "42", ())),759 (["-o", "test", "-a", 42], ("test", "42", ())),760 (["-otest", "-a", 42], ("test", "42", ())),761 (["a", "b", "c"], (None, None, ("a", "b", "c"))),762 (["--opt", "a", "b", "c"], ("a", None, ("b", "c"))),763 (["--opt", "test"], ("test", None, ())),764 (["-otest", "a", "b", "c"], ("test", None, ("a", "b", "c"))),765 (["--opt=test", "a", "b", "c"], ("test", None, ("a", "b", "c"))),766 ],767)768def test_option_with_optional_value(runner, args, expect):769 @click.command()770 @click.option("-o", "--opt", is_flag=False, flag_value="flag")771 @click.option("-a")772 @click.argument("b", nargs=-1)773 def cli(opt, a, b):774 return opt, a, b775776 result = runner.invoke(cli, args, standalone_mode=False, catch_exceptions=False)777 assert result.return_value == expect778779780def test_type_from_flag_value():781 param = click.Option(["-a", "x"], default=True, flag_value=4)782 assert param.type is click.INT783 param = click.Option(["-b", "x"], flag_value=8)784 assert param.type is click.INT785786787@pytest.mark.parametrize(788 ("option", "expected"),789 [790 # Not boolean flags791 pytest.param(Option(["-a"], type=int), False, id="int option"),792 pytest.param(Option(["-a"], type=bool), False, id="bool non-flag [None]"),793 pytest.param(Option(["-a"], default=True), False, id="bool non-flag [True]"),794 pytest.param(Option(["-a"], default=False), False, id="bool non-flag [False]"),795 pytest.param(Option(["-a"], flag_value=1), False, id="non-bool flag_value"),796 # Boolean flags797 pytest.param(Option(["-a"], is_flag=True), True, id="is_flag=True"),798 pytest.param(Option(["-a/-A"]), True, id="secondary option [implicit flag]"),799 pytest.param(Option(["-a"], flag_value=True), True, id="bool flag_value"),800 ],801)802def test_is_bool_flag_is_correctly_set(option, expected):803 assert option.is_bool_flag is expected