def test_resized_images_updated(self):
"""
thumbnails should be updated if image is already present and updated when update_image=True
"""
assert self.profile.image
assert self.profile.image_small
assert self.profile.image_medium
# create a dummy image file in memory for upload
image_file = BytesIO()
image = Image.new('RGBA', size=(50, 50), color=(256, 0, 0))
image.save(image_file, 'png')
image_file.seek(0)
self.profile.image = UploadedFile(image_file, "filename.png", "image/png", len(image_file.getvalue()))
self.profile.save(update_image=True)
image_file_bytes = image_file.read()
assert self.profile.image_small.file.read() != image_file_bytes
assert self.profile.image_medium.file.read() != image_file_bytes
评论列表
文章目录