私はJavaのバックグラウンドから来ており、Pythonでは全く新しいものです。Tornadoサーバーの統合テスト
が、私はそのようなWebサーバーを起動するPythonプログラムhello.py
があるとします。
import tornado.web
import tornado.httpserver
import tornado.ioloop
def start_server(port, handler):
app = tornado.web.Application([(r"/", handler), ])
server = tornado.httpserver.HTTPServer(app)
server.bind(port)
server.start(0) # autodetect number of cores and fork a process for each
tornado.ioloop.IOLoop.instance().start()
class MyHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello!")
start_server(5000, MyHandler)
今、私はPythonでこのサーバーの統合テストを書きたいと思います。テストする必要があります:応答== "Hello!"
を停止した場合、URL http://localhost:5000/hello
に同期し
- 実行
hello.py
どのようにそのようなテストを書くことを提案しますか?
この例のようなものが必要でしょうか? http://www.tornadoweb.org/en/stable/testing.html#tornado.testing.AsyncHTTPTestCase – kepler