From b6f4a92ff45d98a63dc29402d8ad86b88e6a6697 Mon Sep 17 00:00:00 2001 From: Tomek Paczkowski Date: Sat, 23 Feb 2013 19:01:38 +0100 Subject: Proposed fix for #18162. --- tests/regressiontests/model_fields/tests.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/regressiontests/model_fields/tests.py b/tests/regressiontests/model_fields/tests.py index a49894e36c..8c596ed4f5 100644 --- a/tests/regressiontests/model_fields/tests.py +++ b/tests/regressiontests/model_fields/tests.py @@ -73,6 +73,16 @@ 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')] + field = models.CharField(choices=choices) + klass = CustomChoiceField + self.assertIsInstance(field.formfield(form_class=klass), klass) + + class DecimalFieldTests(test.TestCase): def test_to_python(self): f = models.DecimalField(max_digits=4, decimal_places=2) -- cgit v1.3