diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-04-14 12:12:13 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-14 12:12:13 +0200 |
| commit | 1760ad4e8cdbf34a0f38deae300460a0b9c38eac (patch) | |
| tree | 1815c8c1f40069c434fb38e2487036afd64bece5 /tests/model_forms/test_modelchoicefield.py | |
| parent | 08f30d1b6ac9b7bc05857f88a70277d5ceb27ba1 (diff) | |
Relaxed some query ordering assertions in various tests.
It accounts for differences seen on MySQL with MyISAM storage engine.
Diffstat (limited to 'tests/model_forms/test_modelchoicefield.py')
| -rw-r--r-- | tests/model_forms/test_modelchoicefield.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/model_forms/test_modelchoicefield.py b/tests/model_forms/test_modelchoicefield.py index 1ecba4437e..19e9db69a0 100644 --- a/tests/model_forms/test_modelchoicefield.py +++ b/tests/model_forms/test_modelchoicefield.py @@ -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), [ ("", "---------"), |
