Skip to content

Instantly share code, notes, and snippets.

@gilsondev
Last active November 9, 2015 16:13
Show Gist options
  • Save gilsondev/3600648 to your computer and use it in GitHub Desktop.
Save gilsondev/3600648 to your computer and use it in GitHub Desktop.
Cria imagem para ser usados em testes unitários
# -*- 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