The docs don't talk much about these, just basic params with PUT/POST/GET/DELETE, but I have a multipart upload that accompanies PUT, how can I do test it? Thanks!
Asked
Active
Viewed 1,170 times
1 Answers
4
To answer my own question:
builder = EnvironBuilder(method='POST', data={'foo': 'this is some text',
... 'file': (StringIO('my file contents'), 'test.txt')})
Since TestClient is a wrapper around EnvironBuilder, just extend the data dict with a file key, value, and then wrap the file object as a StringIO.

nubela
- 1
- 24
- 75
- 123
-
Thank you for the answer. How did you use the EnvironBuilder to get the response? Would it be the same for uploading other kinds of files? For example: jpeg images. – Primal Pappachan Jun 08 '13 at 13:27
-
@primpap is this the same for images? – user805981 Mar 02 '15 at 05:16