

def test_entity_col_mix_keyed_tuple(self):
    (s, (u1, u2, u3, u4)) = self._fixture()
    User = self.classes.User
    q = s.query(User, User.id)
    kt = (lambda *x: KeyedTuple(x, ['User', 'id']))
    collection = [kt(u1, 1), kt(u2, 2), kt(u3, 7), kt(u4, 8)]
    it = loading.merge_result(q, collection)
    it = list(it)
    eq_([(x.id, y) for (x, y) in it], [(1, 1), (2, 2), (7, 7), (8, 8)])
    eq_(list(it[0].keys()), ['User', 'id'])

dataset/ETHPy150Open zzzeek/sqlalchemy/test/orm/test_loading.py MergeResultTest.test_entity_col_mix_keyed_tuple/original