test_fields.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:django-buckets 作者: Cadasta 项目源码 文件源码
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
#
# #############################################################################
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号