mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Relaxed some query ordering assertions in various tests.
It accounts for differences seen on MySQL with MyISAM storage engine.
This commit is contained in:
@@ -92,7 +92,7 @@ class ModelChoiceFieldTests(TestCase):
|
||||
self.assertEqual(len(f.choices), 2)
|
||||
|
||||
# queryset can be changed after the field is created.
|
||||
f.queryset = Category.objects.exclude(name="Third")
|
||||
f.queryset = Category.objects.exclude(name="Third").order_by("pk")
|
||||
self.assertEqual(
|
||||
list(f.choices),
|
||||
[
|
||||
@@ -119,7 +119,7 @@ class ModelChoiceFieldTests(TestCase):
|
||||
)
|
||||
|
||||
# Overriding label_from_instance() to print custom labels.
|
||||
f.queryset = Category.objects.all()
|
||||
f.queryset = Category.objects.order_by("pk")
|
||||
f.label_from_instance = lambda obj: "category " + str(obj)
|
||||
self.assertEqual(
|
||||
list(f.choices),
|
||||
@@ -132,7 +132,7 @@ class ModelChoiceFieldTests(TestCase):
|
||||
)
|
||||
|
||||
def test_choices_freshness(self):
|
||||
f = forms.ModelChoiceField(Category.objects.all())
|
||||
f = forms.ModelChoiceField(Category.objects.order_by("pk"))
|
||||
self.assertEqual(len(f.choices), 4)
|
||||
self.assertEqual(
|
||||
list(f.choices),
|
||||
@@ -173,7 +173,7 @@ class ModelChoiceFieldTests(TestCase):
|
||||
(self.c2.pk, "A test"),
|
||||
(self.c3.pk, "Third"),
|
||||
]
|
||||
categories = Category.objects.all()
|
||||
categories = Category.objects.order_by("pk")
|
||||
for widget in [forms.RadioSelect, forms.RadioSelect()]:
|
||||
for blank in [True, False]:
|
||||
with self.subTest(widget=widget, blank=blank):
|
||||
@@ -336,7 +336,7 @@ class ModelChoiceFieldTests(TestCase):
|
||||
class CustomModelMultipleChoiceField(forms.ModelMultipleChoiceField):
|
||||
widget = CustomCheckboxSelectMultiple
|
||||
|
||||
field = CustomModelMultipleChoiceField(Category.objects.all())
|
||||
field = CustomModelMultipleChoiceField(Category.objects.order_by("pk"))
|
||||
self.assertHTMLEqual(
|
||||
field.widget.render("name", []),
|
||||
(
|
||||
@@ -382,7 +382,7 @@ class ModelChoiceFieldTests(TestCase):
|
||||
iterator = CustomModelChoiceIterator
|
||||
widget = CustomCheckboxSelectMultiple
|
||||
|
||||
field = CustomModelMultipleChoiceField(Category.objects.all())
|
||||
field = CustomModelMultipleChoiceField(Category.objects.order_by("pk"))
|
||||
self.assertHTMLEqual(
|
||||
field.widget.render("name", []),
|
||||
"""
|
||||
@@ -416,7 +416,7 @@ class ModelChoiceFieldTests(TestCase):
|
||||
def test_queryset_manager(self):
|
||||
f = forms.ModelChoiceField(Category.objects)
|
||||
self.assertEqual(len(f.choices), 4)
|
||||
self.assertEqual(
|
||||
self.assertCountEqual(
|
||||
list(f.choices),
|
||||
[
|
||||
("", "---------"),
|
||||
|
||||
Reference in New Issue
Block a user