Skip to content
Myr

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 file

Take it

The walk stopped after 200 commits: lines older than ea213fc point at it.

Merge pull request #1008 from zacbir/short-helpZachery Birbefore adoptionea213fc

lines 1–5why, one step back
1import click
234def test_basic_defaults(runner):5 @click.command()

Merge branch '7.x'David Lordbefore adoption7239794

line 6why, one step back
6 @click.option("--foo", default=42, type=click.FLOAT)

Merge pull request #1008 from zacbir/short-helpZachery Birbefore adoptionea213fc

lines 7–8why, one step back
7 def cli(foo):
8 assert type(foo) is float

Merge pull request #1532 from pallets/drop-python2David Lordbefore adoption97de2c9

line 9why, one step back
9 click.echo(f"FOO:[{foo}]")

Merge pull request #1008 from zacbir/short-helpZachery Birbefore adoptionea213fc

lines 10–12why, one step back
10
11 result = runner.invoke(cli, [])12 assert not result.exception

Merge branch '7.x'David Lordbefore adoption7239794

line 13why, one step back
13 assert "FOO:[42.0]" in result.output

Merge pull request #1008 from zacbir/short-helpZachery Birbefore adoptionea213fc

lines 14–17why, one step back
14
1516def test_multiple_defaults(runner):17 @click.command()

Merge branch '7.x'David Lordbefore adoption7239794

line 18why, one step back
18 @click.option("--foo", default=[23, 42], type=click.FLOAT, multiple=True)

Merge pull request #1008 from zacbir/short-helpZachery Birbefore adoptionea213fc

lines 19–25why, one step back
19 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.exception

Merge branch '7.x'David Lordbefore adoption7239794

line 26why, one step back
26 assert result.output.splitlines() == ["23.0", "42.0"]

Merge pull request #1008 from zacbir/short-helpZachery Birbefore adoptionea213fc

lines 27–30why, one step back
27
2829def test_nargs_plus_multiple(runner):30 @click.command()

Merge branch '7.x'David Lordbefore adoption7239794

lines 31–33why, one step back
31 @click.option(
32 "--arg", default=((1, 2), (3, 4)), nargs=2, multiple=True, type=click.INT33 )

Merge pull request #1008 from zacbir/short-helpZachery Birbefore adoptionea213fc

line 34why, one step back
34 def cli(arg):

Merge pull request #1532 from pallets/drop-python2David Lordbefore adoption97de2c9

lines 35–36why, one step back
35 for a, b in arg:
36 click.echo(f"<{a:d}|{b:d}>")

Merge pull request #1008 from zacbir/short-helpZachery Birbefore adoptionea213fc

lines 37–39why, one step back
37
38 result = runner.invoke(cli, [])39 assert not result.exception

Merge branch '7.x'David Lordbefore adoption7239794

line 40why, one step back
40 assert result.output.splitlines() == ["<1|2>", "<3|4>"]