def option_map(cmd, is_long): return { x.get_name(is_long): x.display for x in all_options(cmd) if x.name.startswith('-') }
""" c = completer() e = complete_event() c.set_fuzzy_match(True) position = len(command) result = list(c.get_completions( Document(text=command, cursor_position=position), e)) expected = list(map(lambda t: Completion(t, -len(command)), expected)) assert result == expected pso = list(filter(lambda x: x.name.startswith('-'), all_options('ps'))) @pytest.mark.parametrize("command, expected, expected_pos", [ ("ps ", pso, 0), ("ps --", list(filter( lambda x: x.long_name and x.long_name.startswith('--'), pso)), -2), ("ps --h", list(filter( lambda x: x.long_name and x.long_name.startswith('--h'), pso)), -3), ("ps --all ", list(filter( lambda x: x.long_name not in ['--all'], pso)), 0), ("ps --all --quiet ", list(filter( lambda x: x.long_name not in ['--all', '--quiet'], pso)), 0), ]) def test_options_completion_long(command, expected, expected_pos): """