testing - Test file upload in Flask -
i have flask's controller (post) upload file:
f = request.files['external_data'] filename = secure_filename(f.filename) f.save(filename)
i have tried test it:
handle = open(filepath, 'rb') fs = filestorage(stream=handle, filename=filename, name='external_data') payload['files'] = fs url = '/my/upload/url' test_client.post(url, data=payload)
but in controller request.files
contains:
immutablemultidict: immutablemultidict([('files', <filestorage: u'myfile.png' ('image/png')>)])
my tests pass in case replace 'external_data'
'files'
how possible create flask test request contains request.files('external_data')
?
Comments
Post a Comment