Skip to content

Instantly share code, notes, and snippets.

@marcosgabarda
Last active August 29, 2015 14:05
Show Gist options
  • Save marcosgabarda/901c99f5debdb75d47c6 to your computer and use it in GitHub Desktop.
Save marcosgabarda/901c99f5debdb75d47c6 to your computer and use it in GitHub Desktop.
from PIL import Image
def random_image(size=(200, 200)):
""" Generates a random PIL image, for testings propouse.
:param size: Size of the random image generated.
"""
color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255), 0)
return Image.new("RGBA", size, color)
import StringIO
def test_picture_form(self):
"""Sample of test."""
picture = random_image()
picture_file = StringIO.StringIO()
picture.save(picture_file, format="JPEG")
# Use picture for testing...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment