diff options
| author | Carl Meyer <carl@oddbird.net> | 2013-08-29 21:44:37 -0600 |
|---|---|---|
| committer | Carl Meyer <carl@oddbird.net> | 2013-08-30 17:45:14 -0600 |
| commit | 21a3efcf48559b3336ca1743d94c741a82feffd6 (patch) | |
| tree | 6d3140dab63f2f8081d8da4d578e91493dd196c7 /tests/model_fields/tests.py | |
| parent | 1d874ce0f94432c1a4b42cacaeb02c5948000d0f (diff) | |
[1.6.x] Fixed #20999 - Allow overriding formfield class with choices, without subclass restrictions.
Refs #18162. Thanks claudep and mjtamlyn for review.
Backport of 7211741fc5d50425 from master.
Diffstat (limited to 'tests/model_fields/tests.py')
| -rw-r--r-- | tests/model_fields/tests.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py index 432984f6bb..60ce13dfb6 100644 --- a/tests/model_fields/tests.py +++ b/tests/model_fields/tests.py @@ -68,14 +68,12 @@ class BasicFieldTests(test.TestCase): self.assertEqual(m._meta.get_field('id').verbose_name, 'verbose pk') - def test_formclass_with_choices(self): - # regression for 18162 - class CustomChoiceField(forms.TypedChoiceField): - pass - choices = [('a@b.cc', 'a@b.cc'), ('b@b.cc', 'b@b.cc')] + def test_choices_form_class(self): + """Can supply a custom choices form class. Regression for #20999.""" + choices = [('a', 'a')] field = models.CharField(choices=choices) - klass = CustomChoiceField - self.assertIsInstance(field.formfield(form_class=klass), klass) + klass = forms.TypedMultipleChoiceField + self.assertIsInstance(field.formfield(choices_form_class=klass), klass) class DecimalFieldTests(test.TestCase): |
