mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #33308 -- Added support for psycopg version 3.
Thanks Simon Charette, Tim Graham, and Adam Johnson for reviews. Co-authored-by: Florian Apolloner <florian@apolloner.eu> Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
This commit is contained in:
committed by
Mariusz Felisiak
parent
d44ee518c4
commit
09ffc5c121
@@ -454,7 +454,7 @@ class BackendTestCase(TransactionTestCase):
|
||||
with connection.cursor() as cursor:
|
||||
self.assertIsInstance(cursor, CursorWrapper)
|
||||
# Both InterfaceError and ProgrammingError seem to be used when
|
||||
# accessing closed cursor (psycopg2 has InterfaceError, rest seem
|
||||
# accessing closed cursor (psycopg has InterfaceError, rest seem
|
||||
# to use ProgrammingError).
|
||||
with self.assertRaises(connection.features.closed_cursor_error_class):
|
||||
# cursor should be closed, so no queries should be possible.
|
||||
@@ -462,12 +462,12 @@ class BackendTestCase(TransactionTestCase):
|
||||
|
||||
@unittest.skipUnless(
|
||||
connection.vendor == "postgresql",
|
||||
"Psycopg2 specific cursor.closed attribute needed",
|
||||
"Psycopg specific cursor.closed attribute needed",
|
||||
)
|
||||
def test_cursor_contextmanager_closing(self):
|
||||
# There isn't a generic way to test that cursors are closed, but
|
||||
# psycopg2 offers us a way to check that by closed attribute.
|
||||
# So, run only on psycopg2 for that reason.
|
||||
# psycopg offers us a way to check that by closed attribute.
|
||||
# So, run only on psycopg for that reason.
|
||||
with connection.cursor() as cursor:
|
||||
self.assertIsInstance(cursor, CursorWrapper)
|
||||
self.assertTrue(cursor.closed)
|
||||
|
||||
Reference in New Issue
Block a user