test_basic.py
This file
Path
tests/test_basic.py
510 lines · 14.0 KiB · Python
Last changed by
Merge pull request #1303 from robintully/issue_1110_open_intervalDavid Lordbefore adoptionca75bab
History of this fileTake it
The walk stopped after 200 commits: lines older than 55682f6 point at it.
Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 1–2why, one step back1import os2import uuidMerge pull request #1630 from jwodder/more-boolsDavid Lordbefore adoption2815455
line 3why, one step back3from itertools import chainMerge branch '7.x'David Lordbefore adoption7239794
line 4why, one step back4Merge pull request #1630 from jwodder/more-boolsDavid Lordbefore adoption2815455
lines 5–6why, one step back5import pytest6Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 7–13why, one step back7import click8910def test_basic_functionality(runner):11 @click.command()12 def cli():13 """Hello World!"""Merge branch '7.x'David Lordbefore adoption7239794
line 14why, one step back14 click.echo("I EXECUTED")Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 15why, one step back15Merge branch '7.x'David Lordbefore adoption7239794
line 16why, one step back16 result = runner.invoke(cli, ["--help"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 17why, one step back17 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
lines 18–19why, one step back18 assert "Hello World!" in result.output19 assert "Show this message and exit." in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 20why, one step back20 assert result.exit_code == 0Merge branch '7.x'David Lordbefore adoption7239794
line 21why, one step back21 assert "I EXECUTED" not in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 22–24why, one step back2223 result = runner.invoke(cli, [])24 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 25why, one step back25 assert "I EXECUTED" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 26–28why, one step back26 assert result.exit_code == 02728Merge pull request #1295 from jzengg/issue-1267-add-name-to-command-reprDavid Lordbefore adoptione6eac0a
lines 29–41why, one step back29def test_repr():30 @click.command()31 def command():32 pass3334 @click.group()35 def group():36 pass3738 @group.command()39 def subcommand():40 pass41Merge branch '7.x'David Lordbefore adoption7239794
lines 42–44why, one step back42 assert repr(command) == "<Command command>"43 assert repr(group) == "<Group group>"44 assert repr(subcommand) == "<Command subcommand>"Merge pull request #1295 from jzengg/issue-1267-add-name-to-command-reprDavid Lordbefore adoptione6eac0a
lines 45–46why, one step back4546Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 47–51why, one step back47def test_return_values():48 @click.command()49 def cli():50 return 4251Merge branch '7.x'David Lordbefore adoption7239794
line 52why, one step back52 with cli.make_context("foo", []) as ctx:Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 53why, one step back53 rv = cli.invoke(ctx)Merge pull request #1445 from tirkarthi/fix-syntax-warningJoshua Bronsonbefore adoption6c454c8
line 54why, one step back54 assert rv == 42Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 55–60why, one step back555657def test_basic_group(runner):58 @click.group()59 def cli():60 """This is the root."""Merge branch '7.x'David Lordbefore adoption7239794
line 61why, one step back61 click.echo("ROOT EXECUTED")Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 62–65why, one step back6263 @cli.command()64 def subcommand():65 """This is a subcommand."""Merge branch '7.x'David Lordbefore adoption7239794
line 66why, one step back66 click.echo("SUBCOMMAND EXECUTED")Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 67why, one step back67Merge branch '7.x'David Lordbefore adoption7239794
line 68why, one step back68 result = runner.invoke(cli, ["--help"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 69why, one step back69 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
lines 70–72why, one step back70 assert "COMMAND [ARGS]..." in result.output71 assert "This is the root" in result.output72 assert "This is a subcommand." in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 73why, one step back73 assert result.exit_code == 0Merge branch '7.x'David Lordbefore adoption7239794
line 74why, one step back74 assert "ROOT EXECUTED" not in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 75why, one step back75Merge branch '7.x'David Lordbefore adoption7239794
line 76why, one step back76 result = runner.invoke(cli, ["subcommand"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 77–78why, one step back77 assert not result.exception78 assert result.exit_code == 0Merge branch '7.x'David Lordbefore adoption7239794
lines 79–80why, one step back79 assert "ROOT EXECUTED" in result.output80 assert "SUBCOMMAND EXECUTED" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 81–84why, one step back818283def test_basic_option(runner):84 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 85why, one step back85 @click.option("--foo", default="no value")Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 86why, one step back86 def cli(foo):Merge pull request #1532 from pallets/drop-python2David Lordbefore adoption97de2c9
line 87why, one step back87 click.echo(f"FOO:[{foo}]")Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 88–90why, one step back8889 result = runner.invoke(cli, [])90 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 91why, one step back91 assert "FOO:[no value]" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 92why, one step back92Merge branch '7.x'David Lordbefore adoption7239794
line 93why, one step back93 result = runner.invoke(cli, ["--foo=42"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 94why, one step back94 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 95why, one step back95 assert "FOO:[42]" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 96why, one step back96Merge branch '7.x'David Lordbefore adoption7239794
line 97why, one step back97 result = runner.invoke(cli, ["--foo"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 98why, one step back98 assert result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 99why, one step back99 assert "--foo option requires an argument" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 100why, one step back100Merge branch '7.x'David Lordbefore adoption7239794
line 101why, one step back101 result = runner.invoke(cli, ["--foo="])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 102why, one step back102 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 103why, one step back103 assert "FOO:[]" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 104why, one step back104Merge pull request #1532 from pallets/drop-python2David Lordbefore adoption97de2c9
line 105why, one step back105 result = runner.invoke(cli, ["--foo=\N{SNOWMAN}"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 106why, one step back106 assert not result.exceptionMerge pull request #1532 from pallets/drop-python2David Lordbefore adoption97de2c9
line 107why, one step back107 assert "FOO:[\N{SNOWMAN}]" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 108–111why, one step back108109110def test_int_option(runner):111 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 112why, one step back112 @click.option("--foo", default=42)Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 113why, one step back113 def cli(foo):Merge pull request #1532 from pallets/drop-python2David Lordbefore adoption97de2c9
line 114why, one step back114 click.echo(f"FOO:[{foo * 2}]")Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 115–117why, one step back115116 result = runner.invoke(cli, [])117 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 118why, one step back118 assert "FOO:[84]" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 119why, one step back119Merge branch '7.x'David Lordbefore adoption7239794
line 120why, one step back120 result = runner.invoke(cli, ["--foo=23"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 121why, one step back121 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 122why, one step back122 assert "FOO:[46]" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 123why, one step back123Merge branch '7.x'David Lordbefore adoption7239794
line 124why, one step back124 result = runner.invoke(cli, ["--foo=bar"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 125why, one step back125 assert result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 126why, one step back126 assert "Invalid value for '--foo': bar is not a valid integer" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 127–130why, one step back127128129def test_uuid_option(runner):130 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
lines 131–133why, one step back131 @click.option(132 "--u", default="ba122011-349f-423b-873b-9d6a79c688ab", type=click.UUID133 )Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 134–135why, one step back134 def cli(u):135 assert type(u) is uuid.UUIDMerge pull request #1532 from pallets/drop-python2David Lordbefore adoption97de2c9
line 136why, one step back136 click.echo(f"U:[{u}]")Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 137–139why, one step back137138 result = runner.invoke(cli, [])139 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 140why, one step back140 assert "U:[ba122011-349f-423b-873b-9d6a79c688ab]" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 141why, one step back141Merge branch '7.x'David Lordbefore adoption7239794
line 142why, one step back142 result = runner.invoke(cli, ["--u=821592c1-c50e-4971-9cd6-e89dc6832f86"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 143why, one step back143 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 144why, one step back144 assert "U:[821592c1-c50e-4971-9cd6-e89dc6832f86]" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 145why, one step back145Merge branch '7.x'David Lordbefore adoption7239794
line 146why, one step back146 result = runner.invoke(cli, ["--u=bar"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 147why, one step back147 assert result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 148why, one step back148 assert "Invalid value for '--u': bar is not a valid UUID value" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 149–152why, one step back149150151def test_float_option(runner):152 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 153why, one step back153 @click.option("--foo", default=42, type=click.FLOAT)Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 154–155why, one step back154 def cli(foo):155 assert type(foo) is floatMerge pull request #1532 from pallets/drop-python2David Lordbefore adoption97de2c9
line 156why, one step back156 click.echo(f"FOO:[{foo}]")Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 157–159why, one step back157158 result = runner.invoke(cli, [])159 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 160why, one step back160 assert "FOO:[42.0]" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 161why, one step back161Merge branch '7.x'David Lordbefore adoption7239794
line 162why, one step back162 result = runner.invoke(cli, ["--foo=23.5"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 163why, one step back163 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 164why, one step back164 assert "FOO:[23.5]" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 165why, one step back165Merge branch '7.x'David Lordbefore adoption7239794
line 166why, one step back166 result = runner.invoke(cli, ["--foo=bar"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 167why, one step back167 assert result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 168why, one step back168 assert "Invalid value for '--foo': bar is not a valid float" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 169–172why, one step back169170171def test_boolean_option(runner):172 for default in True, False:Merge branch '7.x'David Lordbefore adoption7239794
line 173why, one step back173Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 174why, one step back174 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 175why, one step back175 @click.option("--with-foo/--without-foo", default=default)Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 176–178why, one step back176 def cli(with_foo):177 click.echo(with_foo)178Merge branch '7.x'David Lordbefore adoption7239794
line 179why, one step back179 result = runner.invoke(cli, ["--with-foo"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 180why, one step back180 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
lines 181–182why, one step back181 assert result.output == "True\n"182 result = runner.invoke(cli, ["--without-foo"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 183why, one step back183 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 184why, one step back184 assert result.output == "False\n"Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 185–186why, one step back185 result = runner.invoke(cli, [])186 assert not result.exceptionMerge pull request #1532 from pallets/drop-python2David Lordbefore adoption97de2c9
line 187why, one step back187 assert result.output == f"{default}\n"Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 188–189why, one step back188189 for default in True, False:Merge branch '7.x'David Lordbefore adoption7239794
line 190why, one step back190Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 191why, one step back191 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 192why, one step back192 @click.option("--flag", is_flag=True, default=default)Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 193–195why, one step back193 def cli(flag):194 click.echo(flag)195Merge branch '7.x'David Lordbefore adoption7239794
line 196why, one step back196 result = runner.invoke(cli, ["--flag"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 197why, one step back197 assert not result.exceptionMerge pull request #1532 from pallets/drop-python2David Lordbefore adoption97de2c9
line 198why, one step back198 assert result.output == f"{not default}\n"Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 199–200why, one step back199 result = runner.invoke(cli, [])200 assert not result.exceptionMerge pull request #1532 from pallets/drop-python2David Lordbefore adoption97de2c9
line 201why, one step back201 assert result.output == f"{default}\n"Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 202–203why, one step back202203Merge pull request #1630 from jwodder/more-boolsDavid Lordbefore adoption2815455
lines 204–215why, one step back204@pytest.mark.parametrize(205 ("value", "expect"),206 chain(207 ((x, "True") for x in ("1", "true", "t", "yes", "y", "on")),208 ((x, "False") for x in ("0", "false", "f", "no", "n", "off")),209 ),210)211def test_boolean_conversion(runner, value, expect):212 @click.command()213 @click.option("--flag", type=bool)214 def cli(flag):215 click.echo(flag, nl=False)Merge branch '7.x'David Lordbefore adoption7239794
line 216why, one step back216Merge pull request #1630 from jwodder/more-boolsDavid Lordbefore adoption2815455
lines 217–218why, one step back217 result = runner.invoke(cli, ["--flag", value])218 assert result.output == expectFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 219why, one step back219Merge pull request #1630 from jwodder/more-boolsDavid Lordbefore adoption2815455
lines 220–221why, one step back220 result = runner.invoke(cli, ["--flag", value.title()])221 assert result.output == expectFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 222–225why, one step back222223224def test_file_option(runner):225 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 226why, one step back226 @click.option("--file", type=click.File("w"))Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 227why, one step back227 def input(file):Merge branch '7.x'David Lordbefore adoption7239794
line 228why, one step back228 file.write("Hello World!\n")Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 229–230why, one step back229230 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 231why, one step back231 @click.option("--file", type=click.File("r"))Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 232–235why, one step back232 def output(file):233 click.echo(file.read())234235 with runner.isolated_filesystem():Merge branch '7.x'David Lordbefore adoption7239794
lines 236–237why, one step back236 result_in = runner.invoke(input, ["--file=example.txt"])237 result_out = runner.invoke(output, ["--file=example.txt"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 238–239why, one step back238239 assert not result_in.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 240why, one step back240 assert result_in.output == ""Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 241why, one step back241 assert not result_out.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 242why, one step back242 assert result_out.output == "Hello World!\n\n"Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 243–248why, one step back243244245def test_file_lazy_mode(runner):246 do_io = False247248 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 249why, one step back249 @click.option("--file", type=click.File("w"))Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 250–251why, one step back250 def input(file):251 if do_io:Merge branch '7.x'David Lordbefore adoption7239794
line 252why, one step back252 file.write("Hello World!\n")Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 253–254why, one step back253254 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 255why, one step back255 @click.option("--file", type=click.File("r"))Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 256–259why, one step back256 def output(file):257 pass258259 with runner.isolated_filesystem():Merge branch '7.x'David Lordbefore adoption7239794
line 260why, one step back260 os.mkdir("example.txt")Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 261–262why, one step back261262 do_io = TrueMerge branch '7.x'David Lordbefore adoption7239794
line 263why, one step back263 result_in = runner.invoke(input, ["--file=example.txt"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 264–266why, one step back264 assert result_in.exit_code == 1265266 do_io = FalseMerge branch '7.x'David Lordbefore adoption7239794
line 267why, one step back267 result_in = runner.invoke(input, ["--file=example.txt"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 268–269why, one step back268 assert result_in.exit_code == 0269Merge branch '7.x'David Lordbefore adoption7239794
line 270why, one step back270 result_out = runner.invoke(output, ["--file=example.txt"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 271–273why, one step back271 assert result_out.exception272273 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 274why, one step back274 @click.option("--file", type=click.File("w", lazy=False))Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 275why, one step back275 def input_non_lazy(file):Merge branch '7.x'David Lordbefore adoption7239794
line 276why, one step back276 file.write("Hello World!\n")Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 277–278why, one step back277278 with runner.isolated_filesystem():Merge branch '7.x'David Lordbefore adoption7239794
lines 279–280why, one step back279 os.mkdir("example.txt")280 result_in = runner.invoke(input_non_lazy, ["--file=example.txt"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 281why, one step back281 assert result_in.exit_code == 2Merge branch '7.x'David Lordbefore adoption7239794
lines 282–283why, one step back282 assert (283 "Invalid value for '--file': Could not open file: example.txt"Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 284why, one step back284 in result_in.outputMerge branch '7.x'David Lordbefore adoption7239794
line 285why, one step back285 )Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 286–289why, one step back286287288def test_path_option(runner):289 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 290why, one step back290 @click.option("-O", type=click.Path(file_okay=False, exists=True, writable=True))Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 291why, one step back291 def write_to_dir(o):Merge branch '7.x'David Lordbefore adoption7239794
lines 292–293why, one step back292 with open(os.path.join(o, "foo.txt"), "wb") as f:293 f.write(b"meh\n")Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 294–295why, one step back294295 with runner.isolated_filesystem():Merge branch '7.x'David Lordbefore adoption7239794
line 296why, one step back296 os.mkdir("test")Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 297why, one step back297Merge branch '7.x'David Lordbefore adoption7239794
line 298why, one step back298 result = runner.invoke(write_to_dir, ["-O", "test"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 299–300why, one step back299 assert not result.exception300Merge branch '7.x'David Lordbefore adoption7239794
lines 301–302why, one step back301 with open("test/foo.txt", "rb") as f:302 assert f.read() == b"meh\n"Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 303why, one step back303Merge branch '7.x'David Lordbefore adoption7239794
lines 304–305why, one step back304 result = runner.invoke(write_to_dir, ["-O", "test/foo.txt"])305 assert "is a file" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 306–307why, one step back306307 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 308why, one step back308 @click.option("-f", type=click.Path(exists=True))Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 309why, one step back309 def showtype(f):Merge pull request #1532 from pallets/drop-python2David Lordbefore adoption97de2c9
lines 310–311why, one step back310 click.echo(f"is_file={os.path.isfile(f)}")311 click.echo(f"is_dir={os.path.isdir(f)}")Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 312–313why, one step back312313 with runner.isolated_filesystem():Merge branch '7.x'David Lordbefore adoption7239794
lines 314–315why, one step back314 result = runner.invoke(showtype, ["-f", "xxx"])315 assert "does not exist" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 316why, one step back316Merge branch '7.x'David Lordbefore adoption7239794
lines 317–319why, one step back317 result = runner.invoke(showtype, ["-f", "."])318 assert "is_file=False" in result.output319 assert "is_dir=True" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 320–321why, one step back320321 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 322why, one step back322 @click.option("-f", type=click.Path())Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 323why, one step back323 def exists(f):Merge pull request #1532 from pallets/drop-python2David Lordbefore adoption97de2c9
line 324why, one step back324 click.echo(f"exists={os.path.exists(f)}")Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 325–326why, one step back325326 with runner.isolated_filesystem():Merge branch '7.x'David Lordbefore adoption7239794
lines 327–328why, one step back327 result = runner.invoke(exists, ["-f", "xxx"])328 assert "exists=False" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 329why, one step back329Merge branch '7.x'David Lordbefore adoption7239794
lines 330–331why, one step back330 result = runner.invoke(exists, ["-f", "."])331 assert "exists=True" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 332–335why, one step back332333334def test_choice_option(runner):335 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 336why, one step back336 @click.option("--method", type=click.Choice(["foo", "bar", "baz"]))Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 337–339why, one step back337 def cli(method):338 click.echo(method)339Merge branch '7.x'David Lordbefore adoption7239794
line 340why, one step back340 result = runner.invoke(cli, ["--method=foo"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 341why, one step back341 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 342why, one step back342 assert result.output == "foo\n"Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 343why, one step back343Merge branch '7.x'David Lordbefore adoption7239794
line 344why, one step back344 result = runner.invoke(cli, ["--method=meh"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 345why, one step back345 assert result.exit_code == 2Merge branch '7.x'David Lordbefore adoption7239794
lines 346–349why, one step back346 assert (347 "Invalid value for '--method': invalid choice: meh."348 " (choose from foo, bar, baz)" in result.output349 )Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 350why, one step back350Merge branch '7.x'David Lordbefore adoption7239794
lines 351–352why, one step back351 result = runner.invoke(cli, ["--help"])352 assert "--method [foo|bar|baz]" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 353–354why, one step back353354Merge pull request #1273 from 0xDEC0DE/issue/1272David Lordbefore adoptiond15f740
lines 355–375why, one step back355def test_choice_argument(runner):356 @click.command()357 @click.argument("method", type=click.Choice(["foo", "bar", "baz"]))358 def cli(method):359 click.echo(method)360361 result = runner.invoke(cli, ["foo"])362 assert not result.exception363 assert result.output == "foo\n"364365 result = runner.invoke(cli, ["meh"])366 assert result.exit_code == 2367 assert (368 "Invalid value for '{foo|bar|baz}': invalid choice: meh. "369 "(choose from foo, bar, baz)" in result.output370 )371372 result = runner.invoke(cli, ["--help"])373 assert "{foo|bar|baz}" in result.output374375Merge pull request #1099 from sirosen/type-datetimeDavid Lordbefore adoption2c622ee
lines 376–377why, one step back376def test_datetime_option_default(runner):377 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 378why, one step back378 @click.option("--start_date", type=click.DateTime())Merge pull request #1099 from sirosen/type-datetimeDavid Lordbefore adoption2c622ee
line 379why, one step back379 def cli(start_date):Merge branch '7.x'David Lordbefore adoption7239794
line 380why, one step back380 click.echo(start_date.strftime("%Y-%m-%dT%H:%M:%S"))Merge pull request #1099 from sirosen/type-datetimeDavid Lordbefore adoption2c622ee
line 381why, one step back381Merge branch '7.x'David Lordbefore adoption7239794
line 382why, one step back382 result = runner.invoke(cli, ["--start_date=2015-09-29"])Merge pull request #1099 from sirosen/type-datetimeDavid Lordbefore adoption2c622ee
line 383why, one step back383 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 384why, one step back384 assert result.output == "2015-09-29T00:00:00\n"Merge pull request #1099 from sirosen/type-datetimeDavid Lordbefore adoption2c622ee
line 385why, one step back385Merge branch '7.x'David Lordbefore adoption7239794
line 386why, one step back386 result = runner.invoke(cli, ["--start_date=2015-09-29T09:11:22"])Merge pull request #1099 from sirosen/type-datetimeDavid Lordbefore adoption2c622ee
line 387why, one step back387 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 388why, one step back388 assert result.output == "2015-09-29T09:11:22\n"Merge pull request #1099 from sirosen/type-datetimeDavid Lordbefore adoption2c622ee
line 389why, one step back389Merge branch '7.x'David Lordbefore adoption7239794
line 390why, one step back390 result = runner.invoke(cli, ["--start_date=2015-09"])Merge pull request #1099 from sirosen/type-datetimeDavid Lordbefore adoption2c622ee
line 391why, one step back391 assert result.exit_code == 2Merge branch '7.x'David Lordbefore adoption7239794
lines 392–396why, one step back392 assert (393 "Invalid value for '--start_date':"394 " invalid datetime format: 2015-09."395 " (choose from %Y-%m-%d, %Y-%m-%dT%H:%M:%S, %Y-%m-%d %H:%M:%S)"396 ) in result.outputMerge pull request #1099 from sirosen/type-datetimeDavid Lordbefore adoption2c622ee
line 397why, one step back397Merge branch '7.x'David Lordbefore adoption7239794
lines 398–401why, one step back398 result = runner.invoke(cli, ["--help"])399 assert (400 "--start_date [%Y-%m-%d|%Y-%m-%dT%H:%M:%S|%Y-%m-%d %H:%M:%S]" in result.output401 )Merge pull request #1099 from sirosen/type-datetimeDavid Lordbefore adoption2c622ee
lines 402–405why, one step back402403404def test_datetime_option_custom(runner):405 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 406why, one step back406 @click.option("--start_date", type=click.DateTime(formats=["%A %B %d, %Y"]))Merge pull request #1099 from sirosen/type-datetimeDavid Lordbefore adoption2c622ee
line 407why, one step back407 def cli(start_date):Merge branch '7.x'David Lordbefore adoption7239794
line 408why, one step back408 click.echo(start_date.strftime("%Y-%m-%dT%H:%M:%S"))Merge pull request #1099 from sirosen/type-datetimeDavid Lordbefore adoption2c622ee
line 409why, one step back409Merge branch '7.x'David Lordbefore adoption7239794
line 410why, one step back410 result = runner.invoke(cli, ["--start_date=Wednesday June 05, 2010"])Merge pull request #1099 from sirosen/type-datetimeDavid Lordbefore adoption2c622ee
line 411why, one step back411 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 412why, one step back412 assert result.output == "2010-06-05T00:00:00\n"Merge pull request #1099 from sirosen/type-datetimeDavid Lordbefore adoption2c622ee
lines 413–414why, one step back413414Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 415–416why, one step back415def test_required_option(runner):416 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 417why, one step back417 @click.option("--foo", required=True)Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 418–422why, one step back418 def cli(foo):419 click.echo(foo)420421 result = runner.invoke(cli, [])422 assert result.exit_code == 2Merge branch '7.x'David Lordbefore adoption7239794
line 423why, one step back423 assert "Missing option '--foo'" in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 424–433why, one step back424425426def test_evaluation_order(runner):427 called = []428429 def memo(ctx, param, value):430 called.append(value)431 return value432433 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
lines 434–440why, one step back434 @click.option("--missing", default="missing", is_eager=False, callback=memo)435 @click.option("--eager-flag1", flag_value="eager1", is_eager=True, callback=memo)436 @click.option("--eager-flag2", flag_value="eager2", is_eager=True, callback=memo)437 @click.option("--eager-flag3", flag_value="eager3", is_eager=True, callback=memo)438 @click.option("--normal-flag1", flag_value="normal1", is_eager=False, callback=memo)439 @click.option("--normal-flag2", flag_value="normal2", is_eager=False, callback=memo)440 @click.option("--normal-flag3", flag_value="normal3", is_eager=False, callback=memo)Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 441–443why, one step back441 def cli(**x):442 pass443Merge branch '7.x'David Lordbefore adoption7239794
lines 444–456why, one step back444 result = runner.invoke(445 cli,446 [447 "--eager-flag2",448 "--eager-flag1",449 "--normal-flag2",450 "--eager-flag3",451 "--normal-flag3",452 "--normal-flag3",453 "--normal-flag1",454 "--normal-flag1",455 ],456 )Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 457–458why, one step back457 assert not result.exception458 assert called == [Merge branch '7.x'David Lordbefore adoption7239794
lines 459–465why, one step back459 "eager2",460 "eager1",461 "eager3",462 "normal2",463 "normal3",464 "normal1",465 "missing",Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 466–470why, one step back466 ]467468469def test_hidden_option(runner):470 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 471why, one step back471 @click.option("--nope", hidden=True)Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 472–474why, one step back472 def cli(nope):473 click.echo(nope)474Merge branch '7.x'David Lordbefore adoption7239794
line 475why, one step back475 result = runner.invoke(cli, ["--help"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 476why, one step back476 assert result.exit_code == 0Merge branch '7.x'David Lordbefore adoption7239794
line 477why, one step back477 assert "--nope" not in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 478–488why, one step back478479480def test_hidden_command(runner):481 @click.group()482 def cli():483 pass484485 @cli.command(hidden=True)486 def nope():487 pass488Merge branch '7.x'David Lordbefore adoption7239794
line 489why, one step back489 result = runner.invoke(cli, ["--help"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 490why, one step back490 assert result.exit_code == 0Merge branch '7.x'David Lordbefore adoption7239794
line 491why, one step back491 assert "nope" not in result.outputFix typo (synching -> syncing)mholtzscherbefore adoption55682f6
lines 492–506why, one step back492493494def test_hidden_group(runner):495 @click.group()496 def cli():497 pass498499 @cli.group(hidden=True)500 def subgroup():501 pass502503 @subgroup.command()504 def nope():505 pass506Merge branch '7.x'David Lordbefore adoption7239794
line 507why, one step back507 result = runner.invoke(cli, ["--help"])Fix typo (synching -> syncing)mholtzscherbefore adoption55682f6
line 508why, one step back508 assert result.exit_code == 0Merge branch '7.x'David Lordbefore adoption7239794
lines 509–510why, one step back509 assert "subgroup" not in result.output510 assert "nope" not in result.output