diff options
| author | ksg97031 <ksg97031@gmail.com> | 2023-10-24 00:36:18 +0900 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-10-24 05:31:11 +0200 |
| commit | d22ba0763086f71fb6df8502162ea63944d166b1 (patch) | |
| tree | 9f815814ae6c052c15301ec7f22e456db1a4e36f | |
| parent | 171f91d9ef5177850c2f12b26dd732785f6ac034 (diff) | |
Fixed #34920 -- Made FileExtensionValidator.__eq__() ignore allowed_extensions ordering.
| -rw-r--r-- | django/core/validators.py | 3 | ||||
| -rw-r--r-- | tests/validators/tests.py | 4 |
2 files changed, 6 insertions, 1 deletions
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 @@ -805,6 +805,10 @@ class TestValidatorEquality(TestCase): FileExtensionValidator(["txt", "png"]), ) self.assertEqual( + FileExtensionValidator(["jpg", "png", "txt"]), + FileExtensionValidator(["txt", "jpg", "png"]), + ) + self.assertEqual( FileExtensionValidator(["txt"]), FileExtensionValidator(["txt"], code="invalid_extension"), ) |
