예제 #1
0
def test_completion():
    @click.group()
    def root_command():
        pass

    @root_command.command()
    @click.argument("handler", type=click.Choice(["foo", "bar"]))
    def arg_cmd():
        pass

    c = ClickCompleter(root_command)
    completions = list(c.get_completions(Document(u"arg_cmd ")))

    assert set(x.text for x in completions) == set([u"foo", u"bar"])
예제 #2
0
def test_completion():
    @click.group()
    def root_command():
        pass

    @root_command.command()
    @click.argument('handler', type=click.Choice(['foo', 'bar']))
    def arg_cmd():
        pass

    c = ClickCompleter(root_command)
    completions = list(c.get_completions(Document(u'arg_cmd ')))

    assert set(x.text for x in completions) == set([u'foo', u'bar'])
def test_completion():
    @click.group()
    def foo_group():
        pass

    @foo_group.command()
    def foo_cmd():
        pass

    @click.group()
    def foobar_group():
        pass

    @foobar_group.command()
    def foobar_cmd():
        pass

    c = ClickCompleter(
        click.CommandCollection(sources=[foo_group, foobar_group]))
    completions = list(c.get_completions(Document(u'foo')))

    assert set(x.text for x in completions) == set([u'foo_cmd', u'foobar_cmd'])
예제 #4
0
def test_completion():
    @click.group()
    def root_command():
        pass

    @root_command.group()
    def first_level_command():
        pass

    @first_level_command.command()
    def second_level_command_one():
        pass

    @first_level_command.command()
    def second_level_command_two():
        pass

    c = ClickCompleter(root_command)
    completions = list(c.get_completions(Document(u"first-level-command ")))

    assert set(x.text for x in completions) == set(
        [u"second-level-command-one", u"second-level-command-two"])
예제 #5
0
def test_completion():
    @click.group()
    def root_command():
        pass

    @root_command.group()
    def first_level_command():
        pass

    @first_level_command.command()
    def second_level_command_one():
        pass

    @first_level_command.command()
    def second_level_command_two():
        pass

    c = ClickCompleter(root_command)
    completions = list(c.get_completions(Document(u'first_level_command ')))

    assert set(x.text for x in completions) == set(
        [u'second_level_command_one', u'second_level_command_two'])