From 3b4a5b9f97f113ca5151cff744019e39a1ed7475 Mon Sep 17 00:00:00 2001 From: David Wobrock Date: Sun, 2 Oct 2022 18:53:05 +0200 Subject: Fixed #23353 -- Used "raise from" when raising TransactionManagementError. This change sets the __cause__ attribute to raised exceptions. --- tests/basic/tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/basic') diff --git a/tests/basic/tests.py b/tests/basic/tests.py index 44ace3d684..1d91e39ce9 100644 --- a/tests/basic/tests.py +++ b/tests/basic/tests.py @@ -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 -- cgit v1.3