diff options
| author | Karen Tracey <kmtracey@gmail.com> | 2009-01-18 20:54:42 +0000 |
|---|---|---|
| committer | Karen Tracey <kmtracey@gmail.com> | 2009-01-18 20:54:42 +0000 |
| commit | dd2e1356f014a9869ea3baef1f7efb9f94bf696c (patch) | |
| tree | 4a1ce2e77032e18cca2a6ab13915202f9fc2a594 | |
| parent | 81dfd1f5f037019a227a767877b2124311cff738 (diff) | |
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.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9773 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | tests/regressiontests/serializers_regress/tests.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/regressiontests/serializers_regress/tests.py b/tests/regressiontests/serializers_regress/tests.py index c6167b12e7..4e52d81811 100644 --- a/tests/regressiontests/serializers_regress/tests.py +++ b/tests/regressiontests/serializers_regress/tests.py @@ -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: @@ -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 |
