Hi,
I'm new to tornado unit testing utility and have started to write simple unit test for my application. But, I'm facing some problems.
Here's my code looks like:
in TestMyApp.py:
=================
class TestMyApp(AsyncHTTPTestCase):
"""
"""
def get_app(self):
return my_app.Application()
def test_my_app(self):
self.http_client.fetch(self.get_url('/v1?w=1?&l=1), self.stop)
response = self.wait()
self.assertTrue( m_body, response.body)
if __name__ == '__main__':
unittest.main()
in my_app.py
=================
class Application(tornado.web.Application):
<defined my handlers>
class V1Handler(tornado.web.RequestHandler):
def my_callback(self,response):
<do something with response, render>
@tornado.web.asynchronous
def get(self):
<read headers and cookies, do something>
http_client = tornado.httpclient.AsyncHTTPClient()
http_request = tornado.httpclient.HTTPRequest(<server>,
method="POST", headers=self.application.auth_header,
body=data)
http_client.fetch(http_request,callback=self.my_callback)
But, When I ran the test, it gave me following error.
File "../../tornado/testing.py", line 154, in timeout_func timeout)
AssertionError: Async operation timed out after 5 seconds
Can someone please guide me what I'm doing wrong ?
Regards,
Kandarp Desai