]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Add a test for path arguments in websockets.
authorBen Darnell <ben@bendarnell.com>
Mon, 8 Feb 2016 01:30:14 +0000 (20:30 -0500)
committerBen Darnell <ben@bendarnell.com>
Mon, 8 Feb 2016 01:30:14 +0000 (20:30 -0500)
tornado/test/websocket_test.py

index f0578ba913635246090ccac652dff743b5411c79..ed5c7070fc43fcf8fd9fb2b0fc8b575d35c5fd7b 100644 (file)
@@ -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()