MCPcopy
hub / github.com/django/django / test_filefield_db_default

Method test_filefield_db_default

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

Source from the content-addressed store, hash-verified

911 obj.default.close()
912
913 def test_filefield_db_default(self):
914 temp_storage.save("tests/db_default.txt", ContentFile("default content"))
915 obj = Storage.objects.create()
916 self.assertEqual(obj.db_default.name, "tests/db_default.txt")
917 self.assertEqual(obj.db_default.read(), b"default content")
918 obj.db_default.close()
919
920 # File is not deleted, even if there are no more objects using it.
921 obj.delete()
922 s = Storage()
923 self.assertEqual(s.db_default.name, "tests/db_default.txt")
924 self.assertEqual(s.db_default.read(), b"default content")
925 s.db_default.close()
926
927 def test_empty_upload_to(self):
928 # upload_to can be empty, meaning it does not use subdirectory.

Callers

nothing calls this directly

Calls 7

ContentFileClass · 0.90
StorageClass · 0.70
saveMethod · 0.45
createMethod · 0.45
readMethod · 0.45
closeMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected