@staticmethod
def get_image_file(name='test.png', ext='png', size=(50, 50), color=(256, 0, 0)
    ):
    file_obj = StringIO()
image = Image.new('RGBA', size=size, color=color)
image.save(file_obj, ext)
file_obj.seek(0)
return File(file_obj, name=name)
Django testing model with ImageField