summaryrefslogtreecommitdiff
path: root/tests/validators
diff options
context:
space:
mode:
authorAnubhav Joshi <anubhav9042@gmail.com>2014-07-24 23:31:12 +0530
committerTim Graham <timograham@gmail.com>2014-07-26 10:03:00 -0400
commit5cdb8f8c1ea7161ca9e3b702ec7cdd7e3cd0999a (patch)
tree8d2e9f6134caeec5f86246bd71467649a95fcb9a /tests/validators
parent5a311d2ccc48cb3a89858c92e449ffbfd9cbfb00 (diff)
downloaddjango-5cdb8f8c1ea7161ca9e3b702ec7cdd7e3cd0999a.tar.gz
Fixed #16617 -- Added 'value' to BaseValidator params.
Also allowed overriding the default messages in subclasses of BaseValidator. Thanks sperrygrove for initial patch.
Diffstat (limited to 'tests/validators')
-rw-r--r--tests/validators/tests.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/validators/tests.py b/tests/validators/tests.py
index ccbe1c99b6..cb552619b4 100644
--- a/tests/validators/tests.py
+++ b/tests/validators/tests.py
@@ -14,6 +14,7 @@ from django.core.validators import (
validate_ipv46_address, validate_ipv4_address, validate_ipv6_address,
validate_slug,
)
+from django.test import SimpleTestCase
from django.test.utils import str_prefix
@@ -243,7 +244,7 @@ def create_simple_test_method(validator, expected, value, num):
# Dynamically assemble a test class with the contents of TEST_DATA
-class TestSimpleValidators(TestCase):
+class TestSimpleValidators(SimpleTestCase):
def test_single_message(self):
v = ValidationError('Not Valid')
self.assertEqual(str(v), str_prefix("[%(_)s'Not Valid']"))
@@ -267,6 +268,11 @@ class TestSimpleValidators(TestCase):
else:
self.fail("TypeError not raised when flags and pre-compiled regex in RegexValidator")
+ def test_max_length_validator_message(self):
+ v = MaxLengthValidator(16, message='"%(value)s" has more than %(limit_value)d characters.')
+ with self.assertRaisesMessage(ValidationError, '"djangoproject.com" has more than 16 characters.'):
+ v('djangoproject.com')
+
test_counter = 0
for validator, value, expected in TEST_DATA:
name, method = create_simple_test_method(validator, expected, value, test_counter)