Steve Gattuso Steve Gattuso - 1 year ago 134
Python Question

How do you use tornado.testing for creating WebSocket unit tests?

I'm working on a project that works with tornado's websocket functionality. I see a decent amount of documentation for working with asychronous code, but nothing on how this can be used to create unit tests that work with their WebSocket implementation.


provide the functionality to do this? If so, could someone provide a brief example of how to make it happen?

Thanks in advance.

Answer Source

I've attempted to implement some unit tests on tornado.websocket.WebSocketHandler based handlers and got the following results:

First of all AsyncHTTPTestCase definitely has lack of web sockets support.

Still, one can use it at least to manage IOLoop and application stuff which is significant. Unfortunately, there is no WebSocket client provided with tornado, so here enter side-developed library.

Here is unit test on Web Sockets using Jef Balog's tornado websocket client.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download