diff options
| author | François Freitag <mail@franek.fr> | 2018-02-24 19:38:23 -0800 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-03-01 14:05:35 -0500 |
| commit | 06172d7bc29185b7d37fbf62ec3cfdcfcafb4856 (patch) | |
| tree | b0d4b8790a52a2fdd4d1e32d01b056d96a816c7b /tests/forms_tests | |
| parent | 94a180402c9e52bca2e911b6427c88f436e95449 (diff) | |
Consolidated ModelChoiceField tests.
Diffstat (limited to 'tests/forms_tests')
| -rw-r--r-- | tests/forms_tests/models.py | 7 | ||||
| -rw-r--r-- | tests/forms_tests/tests/tests.py | 24 |
2 files changed, 2 insertions, 29 deletions
diff --git a/tests/forms_tests/models.py b/tests/forms_tests/models.py index fa63d08fd1..327fd7802c 100644 --- a/tests/forms_tests/models.py +++ b/tests/forms_tests/models.py @@ -130,12 +130,5 @@ class FileModel(models.Model): file = models.FileField(storage=temp_storage, upload_to='tests') -class Group(models.Model): - name = models.CharField(max_length=10) - - def __str__(self): - return '%s' % self.name - - class Article(models.Model): content = models.TextField() diff --git a/tests/forms_tests/tests/tests.py b/tests/forms_tests/tests/tests.py index 841a1c6799..de04e8a3bc 100644 --- a/tests/forms_tests/tests/tests.py +++ b/tests/forms_tests/tests/tests.py @@ -2,15 +2,13 @@ import datetime from django.core.files.uploadedfile import SimpleUploadedFile from django.db import models -from django.forms import ( - CharField, FileField, Form, ModelChoiceField, ModelForm, -) +from django.forms import CharField, FileField, Form, ModelForm from django.forms.models import ModelFormMetaclass from django.test import SimpleTestCase, TestCase from ..models import ( BoundaryModel, ChoiceFieldModel, ChoiceModel, ChoiceOptionModel, Defaults, - FileModel, Group, OptionalMultiChoiceModel, + FileModel, OptionalMultiChoiceModel, ) @@ -56,24 +54,6 @@ class FileForm(Form): file1 = FileField() -class TestModelChoiceField(TestCase): - - def test_choices_not_fetched_when_not_rendering(self): - """ - Generating choices for ModelChoiceField should require 1 query (#12510). - """ - self.groups = [Group.objects.create(name=name) for name in 'abc'] - # only one query is required to pull the model from DB - with self.assertNumQueries(1): - field = ModelChoiceField(Group.objects.order_by('-name')) - self.assertEqual('a', field.clean(self.groups[0].pk).name) - - def test_queryset_manager(self): - f = ModelChoiceField(ChoiceOptionModel.objects) - choice = ChoiceOptionModel.objects.create(name="choice 1") - self.assertEqual(list(f.choices), [('', '---------'), (choice.pk, str(choice))]) - - class TestTicket14567(TestCase): """ The return values of ModelMultipleChoiceFields are QuerySets |
