@contextmanager
def make_uploaded_file(content_type, *a, **kw):
 with make_image_file(*a, **kw) as image_file:
  (yield UploadedFile(image_file, content_type=content_type, size=os.path.getsize(image_file.name)))

@ contextmanager def make_uploaded_file ( content_type , * a , ** kw ) : with make_image_file ( * a , ** kw ) as image_file : ( yield UploadedFile ( image_file , content_type = content_type , size = os . path . getsize ( image_file . name ) ) )
wrap the result of make_image_file in a django uploadedfile .