From d22ba0763086f71fb6df8502162ea63944d166b1 Mon Sep 17 00:00:00 2001 From: ksg97031 Date: Tue, 24 Oct 2023 00:36:18 +0900 Subject: [PATCH] Fixed #34920 -- Made FileExtensionValidator.__eq__() ignore allowed_extensions ordering. --- django/core/validators.py | 3 ++- tests/validators/tests.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/django/core/validators.py b/django/core/validators.py index fe8d46526a..a5641d85b3 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -595,7 +595,8 @@ class FileExtensionValidator: def __eq__(self, other): return ( isinstance(other, self.__class__) - and self.allowed_extensions == other.allowed_extensions + and set(self.allowed_extensions or []) + == set(other.allowed_extensions or []) and self.message == other.message and self.code == other.code ) diff --git a/tests/validators/tests.py b/tests/validators/tests.py index cf64638ebb..cae64045bd 100644 --- a/tests/validators/tests.py +++ b/tests/validators/tests.py @@ -804,6 +804,10 @@ class TestValidatorEquality(TestCase): FileExtensionValidator(["TXT", "png"]), FileExtensionValidator(["txt", "png"]), ) + self.assertEqual( + FileExtensionValidator(["jpg", "png", "txt"]), + FileExtensionValidator(["txt", "jpg", "png"]), + ) self.assertEqual( FileExtensionValidator(["txt"]), FileExtensionValidator(["txt"], code="invalid_extension"),