mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #28853 -- Updated connection.cursor() uses to use a context manager.
This commit is contained in:
@@ -26,10 +26,10 @@ class DatabaseErrorWrapperTests(TestCase):
|
||||
|
||||
@unittest.skipUnless(connection.vendor == 'postgresql', 'PostgreSQL test')
|
||||
def test_reraising_backend_specific_database_exception(self):
|
||||
cursor = connection.cursor()
|
||||
msg = 'table "X" does not exist'
|
||||
with self.assertRaisesMessage(ProgrammingError, msg) as cm:
|
||||
cursor.execute('DROP TABLE "X"')
|
||||
with connection.cursor() as cursor:
|
||||
msg = 'table "X" does not exist'
|
||||
with self.assertRaisesMessage(ProgrammingError, msg) as cm:
|
||||
cursor.execute('DROP TABLE "X"')
|
||||
self.assertNotEqual(type(cm.exception), type(cm.exception.__cause__))
|
||||
self.assertIsNotNone(cm.exception.__cause__)
|
||||
self.assertIsNotNone(cm.exception.__cause__.pgcode)
|
||||
|
||||
Reference in New Issue
Block a user