summaryrefslogtreecommitdiff
path: root/tests/validators
diff options
context:
space:
mode:
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)