Tornado: Tornado hello_world test returns 599

Created on 20 Jul 2016  路  8Comments  路  Source: tornadoweb/tornado

I am using Tornado 4.4 with CPython 2.7.

I copied:

import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write("Hello, world")

def make_app():
    return tornado.web.Application([
        (r"/", MainHandler),
    ])

if __name__ == "__main__":
    app = make_app()
    app.listen(8888)
    tornado.ioloop.IOLoop.current().start()

from http://www.tornadoweb.org/en/stable/guide/structure.html to hello.py and then:

import hello

class TestHelloApp(AsyncHTTPTestCase):
    def get_app(self):
        return hello.make_app()

    def test_homepage(self):
        response = self.fetch('/')
        self.assertEqual(response.code, 200)
        self.assertEqual(response.body, 'Hello, world')

from http://www.tornadoweb.org/en/stable/testing.html to test_hello.py

And when I run:

python -m tornado.test.runtests test_hello

I am getting:

AssertionError: 599 != 200.

Either I am missing something or the Tornado docs/code need to be updated.

Most helpful comment

So I found a solution. Not exactly for this example but with same 599 error. When you try send POST or PUT request with .fetch method, you must give it a body argument, even empty one.

All 8 comments

I forgot to mention that I was executing this test in VirtualBox/Ubuntu 14.04. And it turns out this is very important since I am not getting that 599 when I run it directly in OSX or VirtualBox/Debian Jessie.

I'm not sure what's going on here. The code looks correct, and it's working on other platforms. I don't know of any difference between debian jessie and ubuntu 14.04 that would explain this. I think this is more a question of how this particular ubuntu VM is set up.

This explains why I was a bit perplexed when I found it out. I need a bit more testing to find out which parts of VM are causing that issue. I already saw that the test runs fine in the basic Ubuntu 14.04 VM.

Did u work it out ? I encountered the same problem recently . I ensured that the app is available through my web browser when started as a tornado httpserver,while got only 599 error in about 0.004s in a AsyncHTTPTestCase

Did someone figure out, where the problem is?

i think you should provide more information about the vm

So I found a solution. Not exactly for this example but with same 599 error. When you try send POST or PUT request with .fetch method, you must give it a body argument, even empty one.

I think we need a better error message or default body for it, this takes me quite some time to figure out...

Was this page helpful?
0 / 5 - 0 ratings