test_defaults.py
This file
Path
tests/test_defaults.py
40 lines · 1.1 KiB · Python
Last changed by
Merge pull request #1532 from pallets/drop-python2David Lordbefore adoption97de2c9
History of this fileTake it
The walk stopped after 200 commits: lines older than 5210849 point at it.
Merge pull request #806 from stopthatcow/feature/790Markus Unterwaditzerbefore adoption5210849
lines 1–5why, one step back1import click234def test_basic_defaults(runner):5 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 6why, one step back6 @click.option("--foo", default=42, type=click.FLOAT)Merge pull request #806 from stopthatcow/feature/790Markus Unterwaditzerbefore adoption5210849
lines 7–8why, one step back7 def cli(foo):8 assert type(foo) is floatMerge pull request #1532 from pallets/drop-python2David Lordbefore adoption97de2c9
line 9why, one step back9 click.echo(f"FOO:[{foo}]")Merge pull request #806 from stopthatcow/feature/790Markus Unterwaditzerbefore adoption5210849
lines 10–12why, one step back1011 result = runner.invoke(cli, [])12 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 13why, one step back13 assert "FOO:[42.0]" in result.outputMerge pull request #806 from stopthatcow/feature/790Markus Unterwaditzerbefore adoption5210849
lines 14–17why, one step back141516def test_multiple_defaults(runner):17 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
line 18why, one step back18 @click.option("--foo", default=[23, 42], type=click.FLOAT, multiple=True)Merge pull request #806 from stopthatcow/feature/790Markus Unterwaditzerbefore adoption5210849
lines 19–25why, one step back19 def cli(foo):20 for item in foo:21 assert type(item) is float22 click.echo(item)2324 result = runner.invoke(cli, [])25 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 26why, one step back26 assert result.output.splitlines() == ["23.0", "42.0"]Merge pull request #806 from stopthatcow/feature/790Markus Unterwaditzerbefore adoption5210849
lines 27–30why, one step back272829def test_nargs_plus_multiple(runner):30 @click.command()Merge branch '7.x'David Lordbefore adoption7239794
lines 31–33why, one step back31 @click.option(32 "--arg", default=((1, 2), (3, 4)), nargs=2, multiple=True, type=click.INT33 )Merge pull request #806 from stopthatcow/feature/790Markus Unterwaditzerbefore adoption5210849
line 34why, one step back34 def cli(arg):Merge pull request #1532 from pallets/drop-python2David Lordbefore adoption97de2c9
lines 35–36why, one step back35 for a, b in arg:36 click.echo(f"<{a:d}|{b:d}>")Merge pull request #806 from stopthatcow/feature/790Markus Unterwaditzerbefore adoption5210849
lines 37–39why, one step back3738 result = runner.invoke(cli, [])39 assert not result.exceptionMerge branch '7.x'David Lordbefore adoption7239794
line 40why, one step back40 assert result.output.splitlines() == ["<1|2>", "<3|4>"]