summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGaƫl Utard <gael.utard@eedf.fr>2025-02-15 15:55:33 +0100
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-02-17 14:06:03 +0100
commita9d03c409406f3f95f692bc5545ebacc7f4e2e4f (patch)
tree9746260f5fecfcc55555c0c934649ff2aedfacd5 /tests
parent20e965e869d657a3a24ddac6065ee494f283aa18 (diff)
[5.1.x] Fixed #36191 -- Truncated the overwritten file content in FileSystemStorage.
Backport of 0d1dd6bba0c18b7feb6caa5cbd8df80fbac54afd from main.
Diffstat (limited to 'tests')
-rw-r--r--tests/file_storage/tests.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py
index 9b643128d1..7f0a68b0c5 100644
--- a/tests/file_storage/tests.py
+++ b/tests/file_storage/tests.py
@@ -704,6 +704,18 @@ class OverwritingStorageTests(FileStorageTests):
finally:
self.storage.delete(name)
+ def test_save_overwrite_behavior_truncate(self):
+ name = "test.file"
+ original_content = b"content extra extra extra"
+ new_smaller_content = b"content"
+ self.storage.save(name, ContentFile(original_content))
+ try:
+ self.storage.save(name, ContentFile(new_smaller_content))
+ with self.storage.open(name) as fp:
+ self.assertEqual(fp.read(), new_smaller_content)
+ finally:
+ self.storage.delete(name)
+
def test_save_overwrite_behavior_temp_file(self):
"""Saving to same file name twice overwrites the first file."""
name = "test.file"