diff options
author | David Wobrock <david.wobrock@gmail.com> | 2022-10-02 18:53:05 +0200 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-10-03 06:08:54 +0200 |
commit | 3b4a5b9f97f113ca5151cff744019e39a1ed7475 (patch) | |
tree | 6772017c8d6ba1ed54871172852ab31e5210cab9 /tests/transactions | |
parent | da02cbd1effc951b14c981925d0e26a39566649e (diff) | |
download | django-3b4a5b9f97f113ca5151cff744019e39a1ed7475.tar.gz |
Fixed #23353 -- Used "raise from" when raising TransactionManagementError.
This change sets the __cause__ attribute to raised exceptions.
Diffstat (limited to 'tests/transactions')
-rw-r--r-- | tests/transactions/tests.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/transactions/tests.py b/tests/transactions/tests.py index a528ab22e5..bdf912653c 100644 --- a/tests/transactions/tests.py +++ b/tests/transactions/tests.py @@ -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") |