def test_only_change_context_when_in_index(index_data):
    index_data['aws']['arguments'] = ['--region']
    index_data['aws']['commands'] = ['ec2']
    index_data['aws']['children'] = {
        'ec2': {
            'commands': ['create-tags', 'describe-instances'],
            'children': {},
            'argument_metadata': {},
            'arguments': [],
        }
    }
    completer = AWSCLIModelCompleter(index_data)
    c = completer.autocomplete
    partial_cmd = 'ec2 --region us-west-2'
    for i in range(1, len(partial_cmd)):
        c(partial_cmd[:i])

    # We should ignore "us-west-2" because it's not a child
    # of ec2.
    assert c('ec2 --region us-west-2 ') not in ['create-tags', 'describe-instances']
dataset/ETHPy150Open awslabs/aws-shell/tests/unit/test_autocomplete.py/test_only_change_context_when_in_index/operator `==` -> `not in`