summaryrefslogtreecommitdiff
path: root/tests/validators
diff options
context:
space:
mode:
authorDavid Szotten <davidszotten@gmail.com>2014-05-06 21:57:37 +0100
committerAndrew Godwin <andrew@aeracode.org>2014-05-08 19:51:15 -0700
commit7fe60ae64ad712430bce26af7812ed4452a91af0 (patch)
treec1190ca6ac6cd998816a9f3521337d26984b7108 /tests/validators
parent99d9fa329a9da87933ac9eff6c5f9c7514bc9f9a (diff)
Fixed #22588 -- Fix RegexValidator __eq__
Compare parameters instead of re.pattern instances, and add the other parameters to the comparison. Also add a __ne__ to make assertNotEqual work properly.
Diffstat (limited to 'tests/validators')
-rw-r--r--tests/validators/tests.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/validators/tests.py b/tests/validators/tests.py
index 928c482107..d073bf264f 100644
--- a/tests/validators/tests.py
+++ b/tests/validators/tests.py
@@ -296,6 +296,33 @@ class TestValidatorEquality(TestCase):
RegexValidator(r'^(?:[a-z0-9\.\-]*)://'),
)
+ self.assertNotEqual(
+ RegexValidator('', flags=re.IGNORECASE),
+ RegexValidator(''),
+ )
+
+ self.assertNotEqual(
+ RegexValidator(''),
+ RegexValidator('', inverse_match=True),
+ )
+
+ def test_regex_equality_nocache(self):
+ pattern = r'^(?:[a-z0-9\.\-]*)://'
+ left = RegexValidator(pattern)
+ re.purge()
+ right = RegexValidator(pattern)
+
+ self.assertEqual(
+ left,
+ right,
+ )
+
+ def test_regex_equality_blank(self):
+ self.assertEqual(
+ RegexValidator(),
+ RegexValidator(),
+ )
+
def test_email_equality(self):
self.assertEqual(
EmailValidator(),