test_websockethandler.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:django-tornado-websockets 作者: Kocal 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号