summaryrefslogtreecommitdiff
path: root/tests/validators
diff options
context:
space:
mode:
authorDejan Noveski <dr.mote@gmail.com>2014-03-13 12:23:12 +0100
committerErik Romijn <erik@erik.io>2014-03-21 11:12:36 +0100
commit4d0c5f61427a8e67552ee2d777fffbadc7aff3b2 (patch)
tree3a2c5393dbad0163f947cc2944e1f71f27ffd1a1 /tests/validators
parentf2eea960e052db2d280e6dd016b0f8f23d5a8ef7 (diff)
Fixed #22255 -- Added support for specifying re flags in RegexValidator
Diffstat (limited to 'tests/validators')
-rw-r--r--tests/validators/tests.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/validators/tests.py b/tests/validators/tests.py
index b88d71fa68..25f1e1b2f2 100644
--- a/tests/validators/tests.py
+++ b/tests/validators/tests.py
@@ -198,6 +198,10 @@ TEST_DATA = (
(RegexValidator(re.compile('x'), inverse_match=True), 'y', None),
(RegexValidator('x', inverse_match=True), 'x', ValidationError),
(RegexValidator(re.compile('x'), inverse_match=True), 'x', ValidationError),
+
+ (RegexValidator('x', flags=re.IGNORECASE), 'y', ValidationError),
+ (RegexValidator('a'), 'A', ValidationError),
+ (RegexValidator('a', flags=re.IGNORECASE), 'A', None),
)
@@ -250,6 +254,14 @@ class TestSimpleValidators(TestCase):
self.assertEqual(str(v), str_prefix("{%(_)s'first': [%(_)s'First Problem']}"))
self.assertEqual(repr(v), str_prefix("ValidationError({%(_)s'first': [%(_)s'First Problem']})"))
+ def test_regex_validator_flags(self):
+ try:
+ RegexValidator(re.compile('a'), flags=re.IGNORECASE)
+ except TypeError:
+ pass
+ else:
+ self.fail("TypeError not raised when flags and pre-compiled regex in RegexValidator")
+
test_counter = 0
for validator, value, expected in TEST_DATA:
name, method = create_simple_test_method(validator, expected, value, test_counter)