Skip to content
Myr

test_normalization.py

This file

Path

tests/test_normalization.py

39 lines · 956 bytes · Python

Last changed by

Merge pull request #1318 from altendky/1277-altendky-return_exact_from_choice_insensitiveStephen Rosenbefore adoption1a714b3

History of this file

Take it

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

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 1–22why, one step back
1import click
234CONTEXT_SETTINGS = dict(token_normalize_func=lambda x: x.lower())567def test_option_normalization(runner):8 @click.command(context_settings=CONTEXT_SETTINGS)9 @click.option('--foo')10 @click.option('-x')11 def cli(foo, x):12 click.echo(foo)13 click.echo(x)1415 result = runner.invoke(cli, ['--FOO', '42', '-X', 23])16 assert result.output == '42\n23\n'171819def test_choice_normalization(runner):20 @click.command(context_settings=CONTEXT_SETTINGS)21 @click.option('--choice', type=click.Choice(['Foo', 'Bar']))22 def cli(choice):

Merge pull request #1318 from altendky/1277-altendky-return_exact_from_choice_insensitiveStephen Rosenbefore adoption1a714b3

line 23why, one step back
23 click.echo(choice)

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 24–39why, one step back
24
25 result = runner.invoke(cli, ['--CHOICE', 'FOO'])26 assert result.output == 'Foo\n'272829def test_command_normalization(runner):30 @click.group(context_settings=CONTEXT_SETTINGS)31 def cli():32 pass3334 @cli.command()35 def foo():36 click.echo('here!')3738 result = runner.invoke(cli, ['FOO'])39 assert result.output == 'here!\n'