

def test_replace(self):
    (KeywordAssociation, Item, Keyword) = (self.classes.KeywordAssociation, self.classes.Item, self.classes.Keyword)
    sess = create_session()
    item1 = Item('item1')
    item1.keywords.append(KeywordAssociation(Keyword('blue'), 'blue_assoc'))
    item1.keywords.append(KeywordAssociation(Keyword('red'), 'red_assoc'))
    sess.add(item1)
    sess.flush()
    red_keyword = item1.keywords[1].keyword
    del Keyword.keywords[1]
    item1.keywords.append(KeywordAssociation(red_keyword, 'new_red_assoc'))
    sess.flush()
    saved = repr([item1])
    sess.expunge_all()
    l = sess.query(Item).all()
    loaded = repr(l)
    eq_(saved, loaded)

dataset/ETHPy150Open zzzeek/sqlalchemy/test/orm/test_association.py AssociationTest.test_replace/VarMisuse@110/147 `item1`->`Keyword`