jeudi 13 octobre 2016

How to send a file in a tornado.testing.AsyncHTTPTestCase class

I'm trying to send a file in POST using the self.fetch method of tornado.testing.AsyncHTTPTestCase class.

I've just made an application/json request like this:

body = tornado.escape.json_encode({"param1": value1, "param2": value2})
headers = {"Content-Type": "application/json"}

res = self.fetch('/example', method="POST", body=body, headers=headers)
self.assertEqual(res.code, 200)

and it works fine, now I'm wondering if it is possible to make a request like a multipart/form-data.

Is there a way to send a file using self.fetch? Is there another way to test a multipart/form-data in tornado.testing?

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire