def test_delete_file(make_dirs): # noqa
file = create_file()
with open(os.path.join(settings.MEDIA_ROOT,
's3', 'uploads', 'text.txt'), 'wb') as dest_file:
dest_file.write(open(file.name, 'rb').read())
field = S3FileField(storage=FakeS3Storage())
s3_file = S3File('/media/s3/uploads/text.txt', field)
s3_file.file = dest_file
s3_file.delete()
assert not hasattr(s3_file, '_file')
assert not os.path.isfile(
os.path.join(settings.MEDIA_ROOT, 's3', 'uploads', 'text.txt'))
# #############################################################################
#
# S3FileField
#
# #############################################################################
评论列表
文章目录