我使用Rethinkdb和旋風單元測試與rethinkdb.set_loop_type("tornado")
拆機不叫與旋風
我使用python的單元測試來測試我的服務器路線。
這裏是我的單元測試的基類:
class ServerTest(AsyncHTTPTestCase):
def setUp(self):
super(ServerTest, self).setUp()
def get_app(self):
return Application(self.routes, debug = False)
def post(self, route, data):
result = self.fetch("/%s" % route, method = "POST",
body = json.dumps(data)).body
return json.loads(result)
def tearDown(self):
super(ServerTest, self).tearDown()
conn = yield r.connect()
yield r.db("test").table("test_table").delete().run(conn)
conn.close()
我注意到,setUp
運行正常,但tearDown
不是。我所有的單元測試都正確傳遞,但是不會調用tearDown中的打印語句。
編輯:我縮小了它的事實,我打電話yieldD撕下。
編輯:添加@ gen.coroutine到拆解顯示打印語句,但不執行數據庫