def test_can_handle_skips_in_completion(index_data):
    # Normally, completion is always requested char by char.
    # Typing "ec2 describe-inst"
    # will subsequent calls to the autocompleter:
    # 'e', 'ec', 'ec2', 'ec2 ', 'ec2 d', 'ec2 de' ... all the way
    # up to 'ec2 describe-inst'.
    # However, the autocompleter should gracefully handle when there's
    # skips, so two subsequent calls are 'ec' and then 'ec2 describe-ta',
    # the autocompleter should still do the right thing.  The tradeoff
    # will just be that this case will be slower than the common case
    # of char by char additions.
    index_data['aws']['commands'] = ['ec2']
    index_data['aws']['children'] = {
        'ec2': {
            'commands': ['create-tags', 'describe-instances'],
            'argument_metadata': {},
            'arguments': [],
            'children': {
                'create-tags': {
                    'argument_metadata': {
                        '--resources': {'example': '', 'minidoc': 'foo'},
                        '--tags': {'example': 'bar', 'minidoc': 'baz'},
                    },
                    'arguments': ['--resources', '--tags'],
                }
            },
        }
    }
    completer = AWSCLIModelCompleter(index_data)
    c = completer.autocomplete
    result = c('ec2 create-ta')
    assert result == ['create-tags']
dataset/ETHPy150Open awslabs/aws-shell/tests/unit/test_autocomplete.py/test_can_handle_skips_in_completion/original