summaryrefslogtreecommitdiff
path: root/tests/forms_tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/forms_tests')
-rw-r--r--tests/forms_tests/tests/test_validators.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/forms_tests/tests/test_validators.py b/tests/forms_tests/tests/test_validators.py
index bd098d150a..c69597b497 100644
--- a/tests/forms_tests/tests/test_validators.py
+++ b/tests/forms_tests/tests/test_validators.py
@@ -1,5 +1,6 @@
from __future__ import unicode_literals
+import re
from unittest import TestCase
from django import forms
@@ -24,11 +25,22 @@ class UserForm(forms.Form):
)
]
)
+ ignore_case_string = forms.CharField(
+ max_length=50,
+ validators=[
+ validators.RegexValidator(
+ regex='^[a-z]*$',
+ message="Letters only.",
+ flags=re.IGNORECASE,
+ )
+ ]
+
+ )
class TestFieldWithValidators(TestCase):
def test_all_errors_get_reported(self):
- form = UserForm({'full_name': 'not int nor mail', 'string': '2 is not correct'})
+ form = UserForm({'full_name': 'not int nor mail', 'string': '2 is not correct', 'ignore_case_string': "IgnORE Case strIng"})
self.assertRaises(ValidationError, form.fields['full_name'].clean, 'not int nor mail')
try:
@@ -38,3 +50,4 @@ class TestFieldWithValidators(TestCase):
self.assertFalse(form.is_valid())
self.assertEqual(form.errors['string'], ["Letters only."])
+ self.assertEqual(form.errors['string'], ["Letters only."])