python-click/tests/test_bashcomplete.py

21 lines
547 B
Python
Raw Normal View History

2016-04-06 18:13:57 +02:00
# -*- coding: utf-8 -*-
import click
from click._bashcomplete import get_choices
def test_basic():
@click.group()
@click.option('--global-opt')
def cli(global_opt):
pass
@cli.command()
@click.option('--local-opt')
def sub(local_opt):
pass
assert list(get_choices(cli, 'lol', [], '')) == ['sub']
assert list(get_choices(cli, 'lol', [], '-')) == ['--global-opt']
assert list(get_choices(cli, 'lol', ['sub'], '')) == []
assert list(get_choices(cli, 'lol', ['sub'], '-')) == ['--local-opt']