Commits

Mike Bayer committed 36c0cdc

added additional unit test to test that commit errors are detected, rollback occurs in an except:

  • Participants
  • Parent commits d3bfb27

Comments (0)

Files changed (1)

test/engine/transaction.py

         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()