<s> """<STR_LIT>""" <EOL> from StringIO import StringIO <EOL> from PIL import Image as PILImage <EOL> from mock import Mock <EOL> from open_connect . media . models import Image <EOL> from open_connect . connect_core . utils . stringhelp import generate_random_string <EOL> def get_in_memory_image_file ( ) : <EOL> """<STR_LIT>""" <EOL> image_file = StringIO ( ) <EOL> image = PILImage . new ( "<STR_LIT>" , size = ( <NUM_LIT:50> , <NUM_LIT:50> ) , color = ( <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> image . save ( image_file , '<STR_LIT>' ) <EOL> name = '<STR_LIT>' % generate_random_string ( ) <EOL> image_file . name = name <EOL> image_file . width = <NUM_LIT:200> <EOL> image_file . height = <NUM_LIT:200> <EOL> image_file . _committed = False <EOL> image_file . save = Mock ( ) <EOL> image_file . url = '<STR_LIT>' % name <EOL> image_file . __unicode__ = Mock ( return_value = name ) <EOL> image_file . seek ( <NUM_LIT:0> ) <EOL> return image_file <EOL> def get_in_memory_image_instance ( user ) : <EOL> """<STR_LIT>""" <EOL> image = Image ( ) <EOL> image . image = get_in_memory_image_file ( ) <EOL> image . user = user <EOL> image . save ( ) <EOL> return image </s>
