summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHonza Král <honza.kral@gmail.com>2009-06-03 02:39:02 +0000
committerHonza Král <honza.kral@gmail.com>2009-06-03 02:39:02 +0000
commit85e0c469aa5298b54d8d173bf1881b72b3f0c445 (patch)
tree85065fddb20fd48099d5efd8e0e097a36da0ceb5 /tests
parentef84cf85ba98ab4b3b62018a2404b67cd3daf5a4 (diff)
[soc2009/model-validation] added validate_email validator
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/model-validation@10910 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/validators/tests.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/modeltests/validators/tests.py b/tests/modeltests/validators/tests.py
index ffeaeb979a..3a6e223310 100644
--- a/tests/modeltests/validators/tests.py
+++ b/tests/modeltests/validators/tests.py
@@ -1,7 +1,7 @@
from unittest import TestCase
from django.core.exceptions import ValidationError
-from django.core.validators import validate_integer
+from django.core.validators import validate_integer, validate_email
class TestSimpleValidators(TestCase):
pass
@@ -13,9 +13,16 @@ SIMPLE_VALIDATORS_VALUES = (
(validate_integer, -42.5, None),
(validate_integer, None, ValidationError),
(validate_integer, 'a', ValidationError),
+ (validate_email, 'email@here.com', None),
+ (validate_email, 'weirder-email@here.and.there.com', None),
+ (validate_email, None, ValidationError),
+ (validate_email, '', ValidationError),
+ (validate_email, 'abc', ValidationError),
+ (validate_email, 'a @x.cz', ValidationError),
+ (validate_email, 'something@@somewhere.com', ValidationError),
)
-def get_simple_test_func(expected, value, num):
+def get_simple_test_func(validator, expected, value, num):
if isinstance(expected, type) and issubclass(expected, ValidationError):
test_mask = 'test_%s_raises_error_%d'
def test_func(self):
@@ -30,4 +37,4 @@ def get_simple_test_func(expected, value, num):
test_counter = {}
for validator, value, expected in SIMPLE_VALIDATORS_VALUES:
num = test_counter[validator] = test_counter.setdefault(validator, 0) + 1
- setattr(TestSimpleValidators, *get_simple_test_func(expected, value, num))
+ setattr(TestSimpleValidators, *get_simple_test_func(validator, expected, value, num))