1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +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

@@ -805,8 +805,9 @@ class SelectOnSaveTests(TestCase):
"An error occurred in the current transaction. You can't "
"execute queries until the end of the 'atomic' block."
)
with self.assertRaisesMessage(DatabaseError, msg):
with self.assertRaisesMessage(DatabaseError, msg) as cm:
asos.save(update_fields=["pub_date"])
self.assertIsInstance(cm.exception.__cause__, DatabaseError)
finally:
Article._base_manager._queryset_class = orig_class