PageRenderTime 73ms CodeModel.GetById 26ms RepoModel.GetById 5ms app.codeStats 0ms

/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
Possible License(s): BSD-3-Clause
  1. from django import forms
  2. from django.core import validators
  3. from django.core.exceptions import ValidationError
  4. from django.utils.unittest import TestCase
  5. class TestFieldWithValidators(TestCase):
  6. def test_all_errors_get_reported(self):
  7. field = forms.CharField(
  8. validators=[validators.validate_integer, validators.validate_email]
  9. )
  10. self.assertRaises(ValidationError, field.clean, 'not int nor mail')
  11. try:
  12. field.clean('not int nor mail')
  13. except ValidationError, e:
  14. self.assertEqual(2, len(e.messages))