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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -