def test_on_message_when_nonexistent_event(self):
ws_connection = yield self.ws_connect('/ws/test')
# Test when the event is not binded
self.assertDictEqual(self.ws.events, {'hello': ANY})
ws_connection.write_message(json_encode({
'event': 'bye',
'data': {'message': 'Bye !'}
}))
# Throw TimeoutError and/or StopIteration, because WebSocketHandler.on_message() does not send
# any message when the client send a nonexistent event ('bye' in our case).
# Also, I don't know how catch them, because self.assertRaises() and try/catch don't work.
# So I use @unittest.expectedFailure here, but it's a bit dirty imo.
yield ws_connection.read_message()
test_websockethandler.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录