def test_crop(self):
"""Test UPLOADER crop works."""
u = Uploader()
size = (100, 100)
im = Image.new('RGB', size)
folder = tempfile.mkdtemp()
u.upload_folder = folder
im.save(os.path.join(folder, 'image.png'))
coordinates = (0, 0, 50, 50)
file = FileStorage(filename=os.path.join(folder, 'image.png'))
with patch('pybossa.uploader.Image', return_value=True):
err_msg = "It should crop the image"
assert u.crop(file, coordinates) is True, err_msg
with patch('pybossa.uploader.Image.open', side_effect=IOError):
err_msg = "It should return false"
assert u.crop(file, coordinates) is False, err_msg
test_generic_uploader.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录