1
Попытка протестировать запрос POST
с использованием AsyncHTTPTestCase
на Python 3.4, версия Tornado 4.1.AsyncHTTPTestCase Почтовый запрос Передача данных
from tornado.testing import AsyncHTTPTestCase
from myapp import myclass
class TestFooHandler(AsyncHTTPTestCase):
def get_app(self):
return myclass.application
def test_post_handler(self):
import urllib.parse
post_body = urllib.parse.urlencode({"key":"val"})
response = self.fetch("/foo", method="POST", data=post_body)
self.assertEqual(response.code, 200)
Код завершается с сообщением: unexpected keyword argument 'data'
Вот полный след:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/tornado/testing.py", line 120, in __call__
result = self.orig_method(*args, **kwargs)
File "/home/gub/App/unit_tests/test_cors.py", line 22, in test_post_handler
response = self.fetch("/foo", method="POST", data=post_body)
File "/usr/local/lib/python3.4/dist-packages/tornado/testing.py", line 380, in fetch
self.http_client.fetch(self.get_url(path), self.stop, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/tornado/httpclient.py", line 227, in fetch
request = HTTPRequest(url=request, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'data'
Что не правильно с указанным кодом?