MCPcopy
hub / github.com/django/django / test_filefield_write

Method test_filefield_write

tests/file_storage/tests.py:809–819  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

807 obj.normal.close()
808
809 def test_filefield_write(self):
810 # Files can be written to.
811 obj = Storage.objects.create(
812 normal=SimpleUploadedFile("rewritten.txt", b"content")
813 )
814 with obj.normal as normal:
815 normal.open("wb")
816 normal.write(b"updated")
817 obj.refresh_from_db()
818 self.assertEqual(obj.normal.read(), b"updated")
819 obj.normal.close()
820
821 def test_filefield_reopen(self):
822 obj = Storage.objects.create(

Callers

nothing calls this directly

Calls 7

SimpleUploadedFileClass · 0.90
createMethod · 0.45
openMethod · 0.45
writeMethod · 0.45
refresh_from_dbMethod · 0.45
readMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected