Skip to content

Commit

Permalink
Fixed #34920 -- Made FileExtensionValidator.__eq__() ignore allowed_e…
Browse files Browse the repository at this point in the history
…xtensions ordering.
  • Loading branch information
ksg97031 authored and felixxm committed Oct 24, 2023
1 parent 171f91d commit d22ba07
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion django/core/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,8 @@ def __call__(self, value):
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
)
Expand Down
4 changes: 4 additions & 0 deletions tests/validators/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,10 @@ def test_file_extension_equality(self):
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"),
Expand Down

0 comments on commit d22ba07

Please sign in to comment.