def test_autocomp_blank_token(ac_app): """Force a blank token to make sure AutoCompleter consumes them like argparse does""" from cmd2.argparse_completer import AutoCompleter blank = '' # Blank flag arg text = '' line = 'completer -m {} {}'.format(blank, text) endidx = len(line) begidx = endidx - len(text) completer = AutoCompleter(ac_app.completer_parser, ac_app) tokens = ['completer', '-f', blank, text] completions = completer.complete_command(tokens, text, line, begidx, endidx) assert completions == completions_from_function # Blank positional arg text = '' line = 'completer {} {}'.format(blank, text) endidx = len(line) begidx = endidx - len(text) completer = AutoCompleter(ac_app.completer_parser, ac_app) tokens = ['completer', blank, text] completions = completer.complete_command(tokens, text, line, begidx, endidx) assert completions == completions_from_method
def test_complete_command_no_tokens(ac_app): from cmd2.argparse_completer import AutoCompleter parser = Cmd2ArgumentParser() ac = AutoCompleter(parser, ac_app) completions = ac.complete_command(tokens=[], text='', line='', begidx=0, endidx=0) assert not completions