summaryrefslogtreecommitdiff
path: root/tests/regressiontests/forms/fields.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2009-04-16 14:59:37 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2009-04-16 14:59:37 +0000
commit5f20587fcb43cac9a65b72d44a201edf0666dd07 (patch)
treedec6b7aed0bc9cad5c60e24e29925043f1749fd8 /tests/regressiontests/forms/fields.py
parent33eca69b95bb1e7380767b51cfef068088396367 (diff)
[1.0.X] Fixed #9890 -- Modified the regex validation for email addresses to match RFC822/1035. Thanks to ozgur for the report, and kratorius for the patch.
Merge of 10573 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10576 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/forms/fields.py')
-rw-r--r--tests/regressiontests/forms/fields.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/regressiontests/forms/fields.py b/tests/regressiontests/forms/fields.py
index 0dc49f2ca7..bec07dd5c3 100644
--- a/tests/regressiontests/forms/fields.py
+++ b/tests/regressiontests/forms/fields.py
@@ -745,6 +745,27 @@ ValidationError: [u'Enter a valid e-mail address.']
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid e-mail address.']
+>>> f.clean('example@invalid-.com')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid e-mail address.']
+>>> f.clean('example@-invalid.com')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid e-mail address.']
+>>> f.clean('example@inv-.alid-.com')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid e-mail address.']
+>>> f.clean('example@inv-.-alid.com')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid e-mail address.']
+>>> f.clean('example@valid-----hyphens.com')
+u'example@valid-----hyphens.com'
+
+>>> f.clean('example@valid-with-hyphens.com')
+u'example@valid-with-hyphens.com'
>>> f = EmailField(required=False)
>>> f.clean('')
@@ -1104,7 +1125,7 @@ ValidationError: [u'Select a valid choice. 6 is not one of the available choices
# TypedChoiceField ############################################################
-# TypedChoiceField is just like ChoiceField, except that coerced types will
+# TypedChoiceField is just like ChoiceField, except that coerced types will
# be returned:
>>> f = TypedChoiceField(choices=[(1, "+1"), (-1, "-1")], coerce=int)
>>> f.clean('1')
@@ -1122,7 +1143,7 @@ ValidationError: [u'Select a valid choice. 2 is not one of the available choices
# This can also cause weirdness: be careful (bool(-1) == True, remember)
>>> f.coerce = bool
->>> f.clean('-1')
+>>> f.clean('-1')
True
# Even more weirdness: if you have a valid choice but your coercion function