summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorksg <ksg97031@gmail.com>2023-10-28 21:35:25 +0900
committerGitHub <noreply@github.com>2023-10-28 14:35:25 +0200
commita6c7db1d1d77e34600cec5c5044f4e90ed16691f (patch)
treeb9a55e6f0f7206ca3bcb59e583b3598a3096e711
parent8992a0489c01ac8ab7283264a315c005511323e2 (diff)
Fixed #34943 -- Made EmailValidator.__eq__() ignore domain_allowlist ordering.
Signed-off-by: ksg97031 <ksg97031@gmail.com>
-rw-r--r--django/core/validators.py2
-rw-r--r--tests/validators/tests.py4
2 files changed, 5 insertions, 1 deletions
diff --git a/django/core/validators.py b/django/core/validators.py
index a5641d85b3..9b04dad4ab 100644
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -244,7 +244,7 @@ class EmailValidator:
def __eq__(self, other):
return (
isinstance(other, EmailValidator)
- and (self.domain_allowlist == other.domain_allowlist)
+ and (set(self.domain_allowlist) == set(other.domain_allowlist))
and (self.message == other.message)
and (self.code == other.code)
)
diff --git a/tests/validators/tests.py b/tests/validators/tests.py
index cae64045bd..5376517a4a 100644
--- a/tests/validators/tests.py
+++ b/tests/validators/tests.py
@@ -750,6 +750,10 @@ class TestValidatorEquality(TestCase):
EmailValidator(message="BAD EMAIL", code="bad"),
EmailValidator(message="BAD EMAIL", code="bad"),
)
+ self.assertEqual(
+ EmailValidator(allowlist=["127.0.0.1", "localhost"]),
+ EmailValidator(allowlist=["localhost", "127.0.0.1"]),
+ )
def test_basic_equality(self):
self.assertEqual(