summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorDavid Szotten <davidszotten@gmail.com>2014-05-06 21:57:37 +0100
committerDavid Szotten <davidszotten@gmail.com>2014-05-07 19:28:42 +0100
commit724a7bf222e31f42e2ab431cc09da224081d03fa (patch)
tree37600a39766f337782a5eb232ce74fa480800d06 /django
parentf8fa735dc2a0d06e904b458633d0143820a59ac0 (diff)
[1.7.x] 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 'django')
-rw-r--r--django/core/validators.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/django/core/validators.py b/django/core/validators.py
index cc71b72a6a..da59c0e924 100644
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -51,7 +51,17 @@ class RegexValidator(object):
raise ValidationError(self.message, code=self.code)
def __eq__(self, other):
- return isinstance(other, RegexValidator) and (self.regex == other.regex) and (self.message == other.message) and (self.code == other.code)
+ return (
+ isinstance(other, RegexValidator) and
+ self.regex.pattern == other.regex.pattern and
+ self.regex.flags == other.regex.flags and
+ (self.message == other.message) and
+ (self.code == other.code) and
+ (self.inverse_match == other.inverse_match)
+ )
+
+ def __ne__(self, other):
+ return not (self == other)
@deconstructible