def test_stringfield_with_choices_cleans_valid_choice(self):
     f = StringField(max_length=1, choices=[('a','A'), ('b','B')])
     self.assertEqual('a', f.clean('a', None))
 def test_stringfield_raises_error_on_empty_string(self):
     f = StringField()
     self.assertEqual('', f.clean('', None))
Exemple #3
0
 def test_stringfield_500(self):
     f = StringField().formfield()
     value = ''.join('x' for j in xrange(0, 500))
     self.assertEqual(value, f.clean(value))
Exemple #4
0
 def test_stringfield_raises_error_on_empty_string(self):
     f = StringField()
     self.assertRaises(ValidationError, f.clean, "", None)
Exemple #5
0
 def test_stringfield_501(self):
     f = StringField().formfield()
     value = ''.join('x' for j in xrange(0, 501))
     self.assertRaises(ValidationError, f.clean, value)
Exemple #6
0
 def test_stringfield_raises_error_on_empty_input(self):
     f = StringField(null=False)
     self.assertRaises(ValidationError, f.clean, None, None)
Exemple #7
0
 def test_stringfield_with_choices_raises_error_on_invalid_choice(self):
     f = StringField(choices=[('a','A'), ('b','B')])
     self.assertRaises(ValidationError, f.clean, "not a", None)
Exemple #8
0
 def test_stringfield_with_choices_cleans_valid_choice(self):
     f = StringField(max_length=1, choices=[('a','A'), ('b','B')])
     self.assertEqual('a', f.clean('a', None))
Exemple #9
0
 def test_stringfield_cleans_empty_string_when_blank_true(self):
     f = StringField(blank=True)
     self.assertEqual('', f.clean('', None))