[Sqlalchemy-commits] sqlalchemy: move this test to have its own data, avoid FK violat...
Brought to you by:
zzzeek
From: <co...@sq...> - 2013-02-21 20:46:02
|
details: http://hg.sqlalchemy.org/sqlalchemy/sqlalchemy/rev/eba2fe7af227 changeset: 9154:eba2fe7af227 user: Mike Bayer <mi...@zz...> date: Thu Feb 21 15:45:36 2013 -0500 description: move this test to have its own data, avoid FK violations diffstat: test/orm/test_session.py | 39 +++++++++++++++++++++------------------ 1 files changed, 21 insertions(+), 18 deletions(-) diffs (56 lines): diff -r 223b69798ab9 -r eba2fe7af227 test/orm/test_session.py --- a/test/orm/test_session.py Wed Feb 20 18:24:46 2013 -0500 +++ b/test/orm/test_session.py Thu Feb 21 15:45:36 2013 -0500 @@ -780,6 +780,27 @@ go() eq_(canary, [False]) + def test_deleted_expunged(self): + users, User = self.tables.users, self.classes.User + + mapper(User, users) + sess = Session() + sess.add(User(name='x')) + sess.commit() + + u1 = sess.query(User).first() + sess.delete(u1) + + assert not was_deleted(u1) + sess.flush() + + assert was_deleted(u1) + assert u1 not in sess + assert object_session(u1) is sess + sess.commit() + + assert object_session(u1) is None + class SessionStateWFixtureTest(_fixtures.FixtureTest): def test_autoflush_rollback(self): @@ -835,24 +856,6 @@ assert sa.orm.object_session(a) is None assert sa.orm.attributes.instance_state(a).session_id is None - def test_deleted_expunged(self): - users, User = self.tables.users, self.classes.User - - mapper(User, users) - sess = Session() - - u1 = sess.query(User).first() - sess.delete(u1) - - assert not was_deleted(u1) - sess.flush() - - assert was_deleted(u1) - assert u1 not in sess - assert object_session(u1) is sess - sess.commit() - - assert object_session(u1) is None class WeakIdentityMapTest(_fixtures.FixtureTest): |