1
0
mirror of https://github.com/django/django.git synced 2025-02-03 14:16:52 +00:00

Fixed #34920 -- Made FileExtensionValidator.__eq__() ignore allowed_extensions ordering.

This commit is contained in:
ksg97031 2023-10-24 00:36:18 +09:00 committed by Mariusz Felisiak
parent 171f91d9ef
commit d22ba07630
2 changed files with 6 additions and 1 deletions

View File

@ -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
)

View File

@ -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"),