File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 2626from django .test .utils import isolate_apps
2727from django .utils .choices import BlankChoiceIterator
2828from django .utils .deprecation import RemovedInDjango60Warning
29- from django .utils .version import PYPY
29+ from django .utils .version import PY314 , PYPY
3030
3131from .models import (
3232 Article ,
@@ -3048,10 +3048,11 @@ def label_from_instance(self, obj):
30483048 return ", " .join (c .name for c in obj .colours .all ())
30493049
30503050 field = ColorModelChoiceField (ColourfulItem .objects .prefetch_related ("colours" ))
3051- # CPython calls ModelChoiceField.__len__() when coercing to tuple. PyPy
3052- # doesn't call __len__() and so .count() isn't called on the QuerySet.
3053- # The following would trigger an extra query if prefetch were ignored.
3054- with self .assertNumQueries (2 if PYPY else 3 ):
3051+ # CPython < 3.14 calls ModelChoiceField.__len__() when coercing to
3052+ # tuple. PyPy and Python 3.14+ don't call __len__() and so .count()
3053+ # isn't called on the QuerySet. The following would trigger an extra
3054+ # query if prefetch were ignored.
3055+ with self .assertNumQueries (2 if PYPY or PY314 else 3 ):
30553056 self .assertEqual (
30563057 tuple (field .choices ),
30573058 (
You can’t perform that action at this time.
0 commit comments