summaryrefslogtreecommitdiff
path: root/tests/model_forms/tests.py
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2024-12-20 08:43:14 +0100
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-12-20 14:18:10 +0100
commitfcd9d08379a2aee3b2c49eab0d0b8db6fd66d091 (patch)
tree4016bb789e7c529b47c09082ebdf70522b131f28 /tests/model_forms/tests.py
parentf05edb2b43c347d4929efd52c8e2b4e08839f542 (diff)
Refs #35844 -- Fixed OtherModelFormTests.test_prefetch_related_queryset() test on Python 3.14+.
https://github.com/python/cpython/commit/5a23994a3dbee43a0b08f5920032f60f38b63071
Diffstat (limited to 'tests/model_forms/tests.py')
-rw-r--r--tests/model_forms/tests.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
index 4f7fc2c1c0..fd043d3d03 100644
--- a/tests/model_forms/tests.py
+++ b/tests/model_forms/tests.py
@@ -26,7 +26,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 django.utils.version import PY314, PYPY
from .models import (
Article,
@@ -3048,10 +3048,11 @@ class OtherModelFormTests(TestCase):
return ", ".join(c.name for c in obj.colours.all())
field = ColorModelChoiceField(ColourfulItem.objects.prefetch_related("colours"))
- # 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):
+ # CPython < 3.14 calls ModelChoiceField.__len__() when coercing to
+ # tuple. PyPy and Python 3.14+ don'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 or PY314 else 3):
self.assertEqual(
tuple(field.choices),
(