Last active
November 9, 2015 16:13
-
-
Save gilsondev/3600648 to your computer and use it in GitHub Desktop.
Cria imagem para ser usados em testes unitários
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from StringIO import StringIO | |
from PIL import Image | |
def dummy_image(name='image_test', format='png'): | |
"""Gera um imagem para 'mockar' nos testes. Você pode passar | |
os seguintes parametros:: | |
:param name | |
Nome da Imagem. Padrão: ``image_test`` | |
:param format | |
Formato da Imagem (PNG, JPG, etc): Padrão: ``png`` | |
""" | |
file_obj = StringIO() | |
image = Image.new("RGBA", size=(50, 50)) | |
image.save(file_obj, format) | |
file_obj.name = name | |
file_obj.seek(0) | |
return file_obj |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment