def _do_it(args): # generate the argparse.Namespace by parsing the arguments: ns = parser.parse_args(args) # perform the associated callback: result = ns.callback(ns) # display the result: print('{}\n{}'.format(underline(f'{args!r}'), result))
def main(args): setup_model() # create the parser from the dict (flat tree): parser = ParseArg(d=view, root_name='todos') # generate the argparse.Namespace by parsing the arguments: ns = parser.parse_args(args) # perform the associated callback: result = ns.callback(ns) # display the result: print('{}\n\t{}\n'.format(underline(f'{args!r}'), result if result is not None else "SUCCESS"))
def do_it(node): def _do_it(args): # generate the argparse.Namespace by parsing the arguments: ns = parser.parse_args(args) # perform the associated callback: result = ns.callback(ns) # display the result: print('{}\n{}'.format(underline(f'{args!r}'), result)) print(underline(f'\n\nNODE :: {node!r}')) with pytest.raises(SystemExit): _do_it(f'{node} -h') print('\n') _do_it(f'{node}') _do_it(f'{node} -v') _do_it(f'{node} -c') _do_it(f'{node} -v -c')
def test_underline(): s = 'hello, world!' assert underline(s) == 'hello, world!:\n--------------'