Author: kmtracey
Date: 2009-01-18 14:54:42 -0600 (Sun, 18 Jan 2009)
New Revision: 9773

Modified:
   django/trunk/tests/regressiontests/serializers_regress/tests.py
Log:
Corrected code in serializers_regress testcase so that, in the case where an 
exception has been raised, rollback is called before attempting to leave 
transaction management.  With the old code the original exception 
(IntegrityError on InnoDB) was getting hidden by a transaction management error 
resulting from attempting to leave transaction management with a pending 
commit/rollback. 


Modified: django/trunk/tests/regressiontests/serializers_regress/tests.py
===================================================================
--- django/trunk/tests/regressiontests/serializers_regress/tests.py     
2009-01-17 23:06:23 UTC (rev 9772)
+++ django/trunk/tests/regressiontests/serializers_regress/tests.py     
2009-01-18 20:54:42 UTC (rev 9773)
@@ -360,8 +360,11 @@
             objects.extend(func[0](pk, klass, datum))
             instance_count[klass] = 0
         transaction.commit()
-    finally:
+    except:
+        transaction.rollback()
         transaction.leave_transaction_management()
+        raise
+    transaction.leave_transaction_management()
 
     # Get a count of the number of objects created for each class
     for klass in instance_count:
@@ -381,8 +384,11 @@
         for obj in serializers.deserialize(format, serialized_data):
             obj.save()
         transaction.commit()
-    finally:
+    except:
+        transaction.rollback()
         transaction.leave_transaction_management()
+        raise
+    transaction.leave_transaction_management()
 
     # Assert that the deserialized data is the same
     # as the original source


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to