diff options
| author | Chris Sinchok <chris@sinchok.com> | 2016-07-19 15:17:39 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-08-09 12:53:18 -0400 |
| commit | ac1975b18b5a33234284bec86e5a5bb44a4af976 (patch) | |
| tree | 96e5d955b8dc47f8c2df7dab7c701f10f6c89de3 /tests | |
| parent | ade681b9ad2a97833cd3f06530fba01e51250b32 (diff) | |
Fixed #13809 -- Made FieldFile.open() respect its mode argument.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/file_storage/tests.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py index e8425558e8..acb663ef7a 100644 --- a/tests/file_storage/tests.py +++ b/tests/file_storage/tests.py @@ -742,6 +742,16 @@ class FileFieldStorageTests(TestCase): self.assertEqual(list(obj.normal.chunks(chunk_size=2)), [b"co", b"nt", b"en", b"t"]) obj.normal.close() + def test_filefield_write(self): + # Files can be written to. + obj = Storage.objects.create(normal=SimpleUploadedFile('rewritten.txt', b'content')) + with obj.normal as normal: + normal.open('wb') + normal.write(b'updated') + obj.refresh_from_db() + self.assertEqual(obj.normal.read(), b'updated') + obj.normal.close() + def test_filefield_reopen(self): obj = Storage.objects.create(normal=SimpleUploadedFile('reopen.txt', b'content')) with obj.normal as normal: |
