def test_get_invoke_command(self):
        time_str = str(datetime.now())

        @click.command()
        def test_command():
            click.echo(time_str)
            return time_str

        fun = get_invoke(test_command)

        assert callable(fun)

        ret = fun(None, '')

        # Make sure it returned the correct thing
        assert ret is False
Exemple #2
0
    def test_get_invoke_command(self):
        time_str = str(datetime.now())

        @click.command()
        def test_command():
            click.echo(time_str)
            return time_str

        fun = get_invoke(test_command)

        assert callable(fun)

        ret = fun(None, '')

        # Make sure it returned the correct thing
        assert ret is False
    def test_get_invoke_group(self):
        time_str = str(datetime.now())

        @click.group(invoke_without_command=True)
        def main_level():
            pass

        @main_level.group()
        def test_group():
            pass

        @test_group.command()
        def foo():
            click.echo(time_str)
            return time_str

        @test_group.command()
        def bar():
            click.echo('foo')
            return 'foo'

        fun = get_invoke(test_group)

        assert callable(fun)

        # This should be the help function
        ret = fun(None, '')
        assert ret is False

        # Also help
        ret = fun(None, '--help')
        assert ret is False

        # non-existant
        ret = fun(None, 'foobar')
        assert ret is False

        ret = fun(None, 'foo')
        assert ret is False

        ret = fun(None, 'bar')
        assert ret is False
Exemple #4
0
    def test_get_invoke_group(self):
        time_str = str(datetime.now())

        @click.group(invoke_without_command=True)
        def main_level():
            pass

        @main_level.group()
        def test_group():
            pass

        @test_group.command()
        def foo():
            click.echo(time_str)
            return time_str

        @test_group.command()
        def bar():
            click.echo('foo')
            return 'foo'

        fun = get_invoke(test_group)

        assert callable(fun)

        # This should be the help function
        ret = fun(None, '')
        assert ret is False

        # Also help
        ret = fun(None, '--help')
        assert ret is False

        # non-existant
        ret = fun(None, 'foobar')
        assert ret is False

        ret = fun(None, 'foo')
        assert ret is False

        ret = fun(None, 'bar')
        assert ret is False
Exemple #5
0
 def add_command(self, cmd, name):
     # Use the MethodType to add these as bound methods to our current instance
     setattr(self, 'do_%s' % name, get_method_type(get_invoke(cmd), self))
     setattr(self, 'help_%s' % name, get_method_type(get_help(cmd), self))
     setattr(self, 'complete_%s' % name,
             get_method_type(get_complete(cmd), self))