/tests/regressiontests/forms/tests/validators.py
Python | 16 lines | 14 code | 2 blank | 0 comment | 0 complexity | f16b9ebf694cd69cc3fa6c5fc92e5a42 MD5 | raw file
Possible License(s): BSD-3-Clause
1from django import forms 2from django.core import validators 3from django.core.exceptions import ValidationError 4from django.utils.unittest import TestCase 5 6 7class TestFieldWithValidators(TestCase): 8 def test_all_errors_get_reported(self): 9 field = forms.CharField( 10 validators=[validators.validate_integer, validators.validate_email] 11 ) 12 self.assertRaises(ValidationError, field.clean, 'not int nor mail') 13 try: 14 field.clean('not int nor mail') 15 except ValidationError, e: 16 self.assertEqual(2, len(e.messages))