mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #28853 -- Updated connection.cursor() uses to use a context manager.
This commit is contained in:
parent
3308085838
commit
7a6fbf36b1
18 changed files with 234 additions and 257 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue