Skip to content

Instantly share code, notes, and snippets.

@rverton
Created August 2, 2016 15:00
Show Gist options
  • Save rverton/f1542b2c1d7cf0e67e25f4588586bfcf to your computer and use it in GitHub Desktop.
Save rverton/f1542b2c1d7cf0e67e25f4588586bfcf to your computer and use it in GitHub Desktop.
Test file upload with flask (Python3)
from io import BytesIO
def test_file_upload(client):
data = {
'field': 'value',
'file': (BytesIO(b'FILE CONTENT'), 'test.csv')
}
rv = client.post('/upload', buffered=True,
content_type='multipart/form-data',
data=data)
assert rv.status_code == 200
@VP007-py
Copy link

Upon POSTing, I'm getting an error DebugFilesKeyError for which I'm using an exception. Any suggestions on fixing it?

@rverton
Copy link
Author

rverton commented Jun 11, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment