/tests/regressiontests/forms/tests/validators.py
https://code.google.com/p/mango-py/ · Python · 16 lines · 14 code · 2 blank · 0 comment · 2 complexity · f16b9ebf694cd69cc3fa6c5fc92e5a42 MD5 · raw file
- from django import forms
- from django.core import validators
- from django.core.exceptions import ValidationError
- from django.utils.unittest import TestCase
- class TestFieldWithValidators(TestCase):
- def test_all_errors_get_reported(self):
- field = forms.CharField(
- validators=[validators.validate_integer, validators.validate_email]
- )
- self.assertRaises(ValidationError, field.clean, 'not int nor mail')
- try:
- field.clean('not int nor mail')
- except ValidationError, e:
- self.assertEqual(2, len(e.messages))