def test_list_iteration(ut):    
    s = '''
l1 = [1, 2, 3]

def iter_over_list():
    for e in l1:
        return e

r = iter_over_list()


def iter_over_list2():
    for e in list(l1):
        return e


r2 = iter_over_list2()
    '''
    ps.checkString(s)
    r = find_in_history('r', ps)
    ut.assertNums([1, 2, 3], r[0:3])
    ut.assertCont(r[3])

    r = find_in_history('r2', ps)
    # unknown type due to unknown list function
    ut._assertType(TypeError, r[0])
def test_dict_iteration_by_keys_using_explicit_call_to_keys_method(ut):
    '''
    Support the simplest case - one iteration over dictionary using explicit keys() call

    For(target=Name(id='k', ctx=Store()),
        iter=Call(func=Attribute(value=Name(id='dict_', ctx=Load()),
                  attr='keys', ctx=Load()), args=[], keywords=[], starargs=None, kwargs=None),
                  body=[...], orelse=[]) 
    '''
    s = '''
dict_ = {1: 2, 3: 4}

def iter_over_dict_keys():
    for k in dict_.keys():
        # which element returned is undefined
        # (actually, it is defined by the order in which keys are iterated,
        #  which in turn is defined by the hash function, but it's
        #  too complicated)
        # we'll assume that any value can be returned
        return dict_.get(k)

new_values = iter_over_dict_keys()
    '''

    ps.checkString(s)
    r = find_in_history('new_values', ps)
    ut.assertEqual(3, len(r))
    ut.assertNums([2, 4], r[0:2])
    ut.assertCont(r[2])  # represents implicitly returned None