Fixed #20440 -- Ensured CharField's max_length/min_length are integers

This commit is contained in:
Tome Cvitan 2013-05-18 13:26:07 +02:00 committed by Claude Paroz
parent 0038296135
commit caf56ad174
3 changed files with 22 additions and 2 deletions

View file

@ -125,6 +125,15 @@ class FieldsTests(SimpleTestCase):
self.assertEqual(f.max_length, None)
self.assertEqual(f.min_length, 10)
def test_charfield_length_not_int(self):
"""
Ensure that setting min_length or max_length to something that is not a
number returns an exception.
"""
self.assertRaises(ValueError, CharField, min_length='a')
self.assertRaises(ValueError, CharField, max_length='a')
self.assertRaises(ValueError, CharField, 'a')
def test_charfield_widget_attrs(self):
"""
Ensure that CharField.widget_attrs() always returns a dictionary.