1
0
mirror of https://github.com/django/django.git synced 2025-07-19 17:19:12 +00:00

[1.0.X] 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.

r9773 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9774 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Karen Tracey 2009-01-18 22:09:56 +00:00
parent 02980f1c3c
commit 5ce4031a61

View File

@ -360,7 +360,10 @@ def serializerTest(format, self):
objects.extend(func[0](pk, klass, datum)) objects.extend(func[0](pk, klass, datum))
instance_count[klass] = 0 instance_count[klass] = 0
transaction.commit() transaction.commit()
finally: except:
transaction.rollback()
transaction.leave_transaction_management()
raise
transaction.leave_transaction_management() transaction.leave_transaction_management()
# Get a count of the number of objects created for each class # Get a count of the number of objects created for each class
@ -381,7 +384,10 @@ def serializerTest(format, self):
for obj in serializers.deserialize(format, serialized_data): for obj in serializers.deserialize(format, serialized_data):
obj.save() obj.save()
transaction.commit() transaction.commit()
finally: except:
transaction.rollback()
transaction.leave_transaction_management()
raise
transaction.leave_transaction_management() transaction.leave_transaction_management()
# Assert that the deserialized data is the same # Assert that the deserialized data is the same