2016-07-19 2 views
0

CPython 2.7과 함께 토네이도 4.4를 사용하고 있습니다.토네이도 hello_world 테스트 결과 599

http://www.tornadoweb.org/en/stable/guide/structure.html에서
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() 

는 hello.py로하고 :

나는 복사 http://www.tornadoweb.org/en/stable/testing.html에서

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') 

을 test_hello.py을 그리고 실행하면

python -m tornado.test.runtests test_hello

나는 받고있다 :

AssertionError: 599 != 200.

내가 누락되었거나 토네이도 워드 프로세서/코드를 업데이트해야합니다.

답변

0

실수로 코드를 들여 쓰여진 것 같습니다 (hello.py). 이 줄은 전혀 들여 쓰기 안 : 토네이도의 문서 make_app에서

말을하는 것입니다
def make_app(): 

은 모듈 수준의 기능이지만, 코드에서 당신은 그것을 MainHandler의 멤버를했습니다.

+0

제 잘못, 지적 해 주셔서 고맙습니다. 나는 아직도 그것을 얻고있다 599. – pdx9

0

VirtualBox/Ubuntu 14.04에서이 테스트를 실행하고 있다는 것을 잊었습니다. 그리고 이것이 OSX 나 VirtualBox/Debian Jessie에서 직접 실행하면 599가 나오지 않기 때문에 이것이 매우 중요합니다. 우분투 14.04가 Jessie에서 파생 되었기 때문에 나는 여전히 당황스럽고 비슷한 행동을 기대하고있었습니다.