

def _testlist(self, classes):
    sess = create_session()
    count = 1
    obj = None
    for c in classes:
        if isinstance(c, type):
            newobj = c(('item %d' % count))
            count += 1
        else:
            newobj = c
        if (obj is not None):
            obj.nxt = newobj
        else:
            t = newobj
        obj = newobj
    sess.add(t)
    sess.flush()
    assertlist = []
    node = t
    while node:
        assertlist.append(node)
        n = node.nxt
        if (n is not None):
            assert (n.prev is node)
        node = n
    original = repr(assertlist)
    sess.expunge_all()
    node = sess.query(Table1).order_by(Table1.id).filter((Table1.id == t.id)).first()
    assertlist = []
    while node:
        assertlist.append(node)
        n = node.nxt
        if (n is not None):
            assert (n.prev is node)
        node = n
    forwards = repr(assertlist)
    sess.expunge_all()
    node = sess.query(Table1).order_by(Table1.id).filter((Table1.id == obj.id)).first()
    assertlist = []
    while node:
        assertlist.insert(0, node)
        n = node.prev
        if (n is not None):
            assert (n.nxt is node)
        node = n
    backwards = repr(assertlist)
    assert (original == forwards == backwards)

dataset/ETHPy150Open zzzeek/sqlalchemy/test/orm/inheritance/test_poly_linked_list.py PolymorphicCircularTest._testlist/original