test_compat.py
This file
Path
tests/test_compat.py
25 lines · 813 bytes · Python
Last changed by
Merge pull request #865 from stopthatcow/feature/323David Lordbefore adoption39e46e0
History of this fileTake it
1import click2import pytest345if click.__version__ >= '3.0':6 def test_legacy_callbacks(runner):7 def legacy_callback(ctx, value):8 return value.upper()910 @click.command()11 @click.option('--foo', callback=legacy_callback)12 def cli(foo):13 click.echo(foo)1415 with pytest.warns(Warning, match='Invoked legacy parameter callback'):16 result = runner.invoke(cli, ['--foo', 'wat'])17 assert result.exit_code == 018 assert 'WAT' in result.output192021def test_bash_func_name():22 from click._bashcomplete import get_completion_script23 script = get_completion_script('foo-bar baz_blah', '_COMPLETE_VAR', 'bash').strip()24 assert script.startswith('_foo_barbaz_blah_completion()')25 assert '_COMPLETE_VAR=complete $1' in script