Exemplo n.º 1
0
def test_function_registration():
    """
    Pin-point a nasty bug that was occurring due to a wrong name..
    """

    cli = CliApp()

    def hello(name='world'):
        pass

    func_info = cli._analyze_function(hello)
    assert func_info['keyword_args'] == [('name', 'world')]

    a, kw = cli._arg_from_free_value('name', 'world')
    assert a == ('--name', )
    assert kw == {'default': 'world', 'type': str}

    subparser = cli._register_command(hello)
    assert subparser.get_default('func').func is hello
    assert subparser.get_default('name') == 'world'
Exemplo n.º 2
0
def test_function_registration():
    """
    Pin-point a nasty bug that was occurring due to a wrong name..
    """

    cli = CliApp()

    def hello(name='world'):
        pass

    func_info = cli._analyze_function(hello)
    assert func_info['keyword_args'] == [('name', 'world')]

    a, kw = cli._arg_from_free_value('name', 'world')
    assert a == ('--name',)
    assert kw == {'default': 'world', 'type': str}

    subparser = cli._register_command(hello)
    assert subparser.get_default('func').func is hello
    assert subparser.get_default('name') == 'world'