mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Refs #34986 -- Fixed backends.postgresql.test_server_side_cursors.ServerSideCursorsPostgres tests for PyPy.
This commit is contained in:
parent
958a590e53
commit
af6e7e3de8
@ -5,6 +5,8 @@ from contextlib import contextmanager
|
||||
|
||||
from django.db import connection, models
|
||||
from django.test import TestCase
|
||||
from django.test.utils import garbage_collect
|
||||
from django.utils.version import PYPY
|
||||
|
||||
from ..models import Person
|
||||
|
||||
@ -88,14 +90,21 @@ class ServerSideCursorsPostgres(TestCase):
|
||||
persons = Person.objects.iterator()
|
||||
next(persons) # Open a server-side cursor
|
||||
del persons
|
||||
garbage_collect()
|
||||
cursors = self.inspect_cursors()
|
||||
self.assertEqual(len(cursors), 0)
|
||||
|
||||
@unittest.skipIf(
|
||||
PYPY,
|
||||
reason="Cursor not closed properly due to differences in garbage collection.",
|
||||
)
|
||||
def test_server_side_cursors_setting(self):
|
||||
with self.override_db_setting(DISABLE_SERVER_SIDE_CURSORS=False):
|
||||
persons = Person.objects.iterator()
|
||||
self.assertUsesCursor(persons)
|
||||
del persons # Close server-side cursor
|
||||
|
||||
# On PyPy, the cursor is left open here and attempting to force garbage
|
||||
# collection breaks the transaction wrapping the test.
|
||||
with self.override_db_setting(DISABLE_SERVER_SIDE_CURSORS=True):
|
||||
self.assertNotUsesCursor(Person.objects.iterator())
|
||||
|
Loading…
Reference in New Issue
Block a user