diff options
| author | Dejan Noveski <dr.mote@gmail.com> | 2014-03-13 12:23:12 +0100 |
|---|---|---|
| committer | Erik Romijn <erik@erik.io> | 2014-03-21 11:12:36 +0100 |
| commit | 4d0c5f61427a8e67552ee2d777fffbadc7aff3b2 (patch) | |
| tree | 3a2c5393dbad0163f947cc2944e1f71f27ffd1a1 /tests/forms_tests | |
| parent | f2eea960e052db2d280e6dd016b0f8f23d5a8ef7 (diff) | |
Fixed #22255 -- Added support for specifying re flags in RegexValidator
Diffstat (limited to 'tests/forms_tests')
| -rw-r--r-- | tests/forms_tests/tests/test_validators.py | 15 |
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."]) |
