diff options
| author | Gaƫl Utard <gael.utard@eedf.fr> | 2025-02-15 15:55:33 +0100 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-02-17 14:01:00 +0100 |
| commit | 0d1dd6bba0c18b7feb6caa5cbd8df80fbac54afd (patch) | |
| tree | 2105176ab2903fe8a7dfc5cef82d8340f2f96c89 /tests/file_storage | |
| parent | 2fa1f99ab49ae5b6bc0a15ed9398d6fa2996f02a (diff) | |
Fixed #36191 -- Truncated the overwritten file content in FileSystemStorage.
Diffstat (limited to 'tests/file_storage')
| -rw-r--r-- | tests/file_storage/tests.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py index c048b8f071..70c7a4f15f 100644 --- a/tests/file_storage/tests.py +++ b/tests/file_storage/tests.py @@ -634,6 +634,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" |
