def test_basics_13(): config = Config() config.TYPE_OF_VARIABLE_INDEXED_WITH_INTEGER_TYPE = 'tuple' template = ''' {% for x in xs %} {{ x[2] }} {{ x[3] }} {% endfor %} ''' struct = infer(template, config) expected_struct = Dictionary({ 'xs': List(Tuple(( Unknown(label=None, linenos=[]), Unknown(label=None, linenos=[]), Scalar(label=None, linenos=[3]), Scalar(label=None, linenos=[4]), ), label='x', linenos=[3, 4]), label='xs', linenos=[2]) }) assert struct == expected_struct
def test_getitem_3(): template = '''{{ a[3] }}''' ast = parse(template).find(nodes.Getitem) config = Config() config.TYPE_OF_VARIABLE_INDEXED_WITH_INTEGER_TYPE = 'tuple' rtype, struct = visit_getitem(ast, get_scalar_context(ast), {}, config) expected_struct = Dictionary({ 'a': Tuple([ Unknown(), Unknown(), Unknown(), Scalar(linenos=[1]), ], label='a', linenos=[1]), }) assert struct == expected_struct
def test_getitem_3(): template = '''{{ a[3] }}''' ast = parse(template).find(nodes.Getitem) config = Config() config.TYPE_OF_VARIABLE_INDEXED_WITH_INTEGER_TYPE = 'tuple' rtype, struct = visit_getitem(ast, get_scalar_context(ast), {}, config) expected_struct = Dictionary({ 'a': Tuple([ Unknown(), Unknown(), Unknown(), Scalar(linenos=[1]), ], label='a', linenos=[1]), }) assert struct == expected_struct
def test_basics_13(): config = Config() config.TYPE_OF_VARIABLE_INDEXED_WITH_INTEGER_TYPE = 'tuple' template = ''' {% for x in xs %} {{ x[2] }} {{ x[3] }} {% endfor %} ''' struct = infer(template, config) expected_struct = Dictionary({ 'xs': List(Tuple(( Unknown(label=None, linenos=[]), Unknown(label=None, linenos=[]), Scalar(label=None, linenos=[3]), Scalar(label=None, linenos=[4]), ), label='x', linenos=[3, 4]), label='xs', linenos=[2]) }) assert struct == expected_struct