From: Mike Bayer Date: Thu, 14 Dec 2006 23:10:10 +0000 (+0000) Subject: added additional unit test to test that commit errors are detected, rollback occurs... X-Git-Tag: rel_0_3_3~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a59bbed499395a0ae4a5eb08fdad708e2c43ca5;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git added additional unit test to test that commit errors are detected, rollback occurs in an except: --- diff --git a/test/engine/transaction.py b/test/engine/transaction.py index cbd3a1950a..c89bf4b145 100644 --- a/test/engine/transaction.py +++ b/test/engine/transaction.py @@ -51,6 +51,24 @@ class TransactionTest(testbase.PersistTest): assert len(result.fetchall()) == 0 connection.close() + def testraise(self): + connection = testbase.db.connect() + + transaction = connection.begin() + try: + connection.execute(users.insert(), user_id=1, user_name='user1') + connection.execute(users.insert(), user_id=2, user_name='user2') + connection.execute(users.insert(), user_id=1, user_name='user3') + transaction.commit() + assert False + except Exception , e: + print "Exception: ", e + transaction.rollback() + + result = connection.execute("select * from query_users") + assert len(result.fetchall()) == 0 + connection.close() + def testnestedrollback(self): connection = testbase.db.connect()