3

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!

Paco
  • 4,520
  • 3
  • 29
  • 53
nubela
  • 1
  • 24
  • 75
  • 123

1 Answers1

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