Skip to content
Myr

test_compat.py

This file

Path

tests/test_compat.py

24 lines · 768 bytes · Python

Last changed by

Fixed generated bash complete function name. This fixes #221Armin Ronacherbefore adoption7c138a6

History of this file

Take it

1import click234if click.__version__ >= '3.0':5    def test_legacy_callbacks(runner):6        def legacy_callback(ctx, value):7            return value.upper()89        @click.command()10        @click.option('--foo', callback=legacy_callback)11        def cli(foo):12            click.echo(foo)1314        result = runner.invoke(cli, ['--foo', 'wat'])15        assert result.exit_code == 016        assert 'WAT' in result.output17        assert 'Invoked legacy parameter callback' in result.output181920def test_bash_func_name():21    from click._bashcomplete import get_completion_script22    script = get_completion_script('foo-bar baz_blah', '_COMPLETE_VAR').strip()23    assert script.startswith('_foo_barbaz_blah_completion()')24    assert '_COMPLETE_VAR=complete $1' in script