mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
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.
This commit is contained in:
committed by
Andrew Godwin
parent
99d9fa329a
commit
7fe60ae64a
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user