From 95c74b9d699c29fe808684774548e2864d64665a Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 4 Mar 2014 14:12:13 +0000 Subject: Fixed #22206 -- Passed models.TextField.max_length to forms.CharField.maxlength --- tests/model_fields/tests.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/model_fields') diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py index f9d1a76078..194219a114 100644 --- a/tests/model_fields/tests.py +++ b/tests/model_fields/tests.py @@ -203,6 +203,21 @@ class BooleanFieldTests(unittest.TestCase): def test_nullbooleanfield_to_python(self): self._test_to_python(models.NullBooleanField()) + def test_charfield_textfield_max_length_passed_to_formfield(self): + """ + Test that CharField and TextField pass their max_length attributes to + form fields created using their .formfield() method (#22206). + """ + cf1 = models.CharField() + cf2 = models.CharField(max_length=1234) + self.assertIsNone(cf1.formfield().max_length) + self.assertEqual(1234, cf2.formfield().max_length) + + tf1 = models.TextField() + tf2 = models.TextField(max_length=2345) + self.assertIsNone(tf1.formfield().max_length) + self.assertEqual(2345, tf2.formfield().max_length) + def test_booleanfield_choices_blank(self): """ Test that BooleanField with choices and defaults doesn't generate a -- cgit v1.3