1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #23353 -- Used "raise from" when raising TransactionManagementError.

This change sets the __cause__ attribute to raised exceptions.
This commit is contained in:
David Wobrock
2022-10-02 18:53:05 +02:00
committed by Mariusz Felisiak
parent da02cbd1ef
commit 3b4a5b9f97
4 changed files with 10 additions and 4 deletions

View File

@@ -339,8 +339,11 @@ class AtomicErrorsTests(TransactionTestCase):
"An error occurred in the current transaction. You can't "
"execute queries until the end of the 'atomic' block."
)
with self.assertRaisesMessage(transaction.TransactionManagementError, msg):
with self.assertRaisesMessage(
transaction.TransactionManagementError, msg
) as cm:
r2.save(force_update=True)
self.assertIsInstance(cm.exception.__cause__, IntegrityError)
self.assertEqual(Reporter.objects.get(pk=r1.pk).last_name, "Haddock")
@skipIfDBFeature("atomic_transactions")