Skip to content

Commit

Permalink
[1.0.X] Corrected code in serializers_regress testcase so that, in th…
Browse files Browse the repository at this point in the history
…e 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
  • Loading branch information
kmtracey committed Jan 18, 2009
1 parent 02980f1 commit 5ce4031
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/regressiontests/serializers_regress/tests.py
Expand Up @@ -360,8 +360,11 @@ def serializerTest(format, self):
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:
Expand All @@ -381,8 +384,11 @@ def serializerTest(format, self):
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
Expand Down

0 comments on commit 5ce4031

Please sign in to comment.