From: Ben Darnell Date: Mon, 8 Feb 2016 01:30:14 +0000 (-0500) Subject: Add a test for path arguments in websockets. X-Git-Tag: v4.4.0b1~55 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02dc4f7a1893d3f937d91d4b0df74f6e938c3a45;p=thirdparty%2Ftornado.git Add a test for path arguments in websockets. --- diff --git a/tornado/test/websocket_test.py b/tornado/test/websocket_test.py index f0578ba91..ed5c7070f 100644 --- a/tornado/test/websocket_test.py +++ b/tornado/test/websocket_test.py @@ -87,6 +87,11 @@ class AsyncPrepareHandler(TestWebSocketHandler): self.write_message(message) +class PathArgsHandler(TestWebSocketHandler): + def open(self, arg): + self.write_message(arg) + + class WebSocketBaseTestCase(AsyncHTTPTestCase): @gen.coroutine def ws_connect(self, path, compression_options=None): @@ -119,6 +124,8 @@ class WebSocketTest(WebSocketBaseTestCase): dict(close_future=self.close_future)), ('/async_prepare', AsyncPrepareHandler, dict(close_future=self.close_future)), + ('/path_args/(.*)', PathArgsHandler, + dict(close_future=self.close_future)), ]) def test_http_request(self): @@ -246,6 +253,12 @@ class WebSocketTest(WebSocketBaseTestCase): res = yield ws.read_message() self.assertEqual(res, 'hello') + @gen_test + def test_path_args(self): + ws = yield self.ws_connect('/path_args/hello') + res = yield ws.read_message() + self.assertEqual(res, 'hello') + @gen_test def test_check_origin_valid_no_path(self): port = self.get_http_port()