mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #26398 -- Made FieldFile.open() respect its mode argument.
This commit is contained in:
parent
9390da7fb6
commit
a52a531a8b
2 changed files with 13 additions and 4 deletions
|
@ -710,6 +710,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_duplicate_filename(self):
|
||||
# Multiple files with the same name get _(7 random chars) appended to them.
|
||||
objs = [Storage() for i in range(2)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue