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'
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'