Skip to content
Myr

test_normalization.py

This file

Path

tests/test_normalization.py

39 lines · 955 bytes · Python

Last changed by

defaults -> settingsArmin Ronacherbefore adoption1bc0a19

History of this file

Take it

1import click234CONTEXT_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):23        click.echo('Foo')2425    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'