Skip to content

Instantly share code, notes, and snippets.

@abmohan
Forked from rverton/test_file_upload.py
Created July 1, 2020 05:15
Show Gist options
  • Save abmohan/2ffbdf33afdf419abea92c572932e69d to your computer and use it in GitHub Desktop.
Save abmohan/2ffbdf33afdf419abea92c572932e69d 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment