mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #34986 -- Fixed some test assertions for PyPy.
These failures were due to minor inconsistencies or implementation differences between CPython and PyPy.
This commit is contained in:
committed by
Mariusz Felisiak
parent
051dbb5388
commit
baf705f34a
@@ -25,6 +25,7 @@ from django.test import SimpleTestCase, TestCase, ignore_warnings, skipUnlessDBF
|
||||
from django.test.utils import isolate_apps
|
||||
from django.utils.choices import BlankChoiceIterator
|
||||
from django.utils.deprecation import RemovedInDjango60Warning
|
||||
from django.utils.version import PYPY
|
||||
|
||||
from .models import (
|
||||
Article,
|
||||
@@ -3017,7 +3018,10 @@ class OtherModelFormTests(TestCase):
|
||||
return ", ".join(c.name for c in obj.colours.all())
|
||||
|
||||
field = ColorModelChoiceField(ColourfulItem.objects.prefetch_related("colours"))
|
||||
with self.assertNumQueries(3): # would be 4 if prefetch is ignored
|
||||
# CPython calls ModelChoiceField.__len__() when coercing to tuple. PyPy
|
||||
# doesn't call __len__() and so .count() isn't called on the QuerySet.
|
||||
# The following would trigger an extra query if prefetch were ignored.
|
||||
with self.assertNumQueries(2 if PYPY else 3):
|
||||
self.assertEqual(
|
||||
tuple(field.choices),
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user