From 79c605680e015c032ef129433f12e1851b14da83 Mon Sep 17 00:00:00 2001 From: Pierce Lopez Date: Tue, 22 Sep 2020 19:26:06 -0400 Subject: [PATCH] websocket_test: test websocket_connect redirect raises exception instead of "uncaught exception" and then test timeout --- tornado/test/websocket_test.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tornado/test/websocket_test.py b/tornado/test/websocket_test.py index 766b14b861..befe06dd39 100644 --- a/tornado/test/websocket_test.py +++ b/tornado/test/websocket_test.py @@ -111,6 +111,11 @@ def get(self): self.write("ok") +class RedirectHandler(RequestHandler): + def get(self): + self.redirect("/echo") + + class CloseReasonHandler(TestWebSocketHandler): def open(self): self.on_close_called = False @@ -221,6 +226,7 @@ def get_app(self): [ ("/echo", EchoHandler, dict(close_future=self.close_future)), ("/non_ws", NonWebSocketHandler), + ("/redirect", RedirectHandler), ("/header", HeaderHandler, dict(close_future=self.close_future)), ( "/header_echo", @@ -365,6 +371,11 @@ def test_websocket_http_success(self): with self.assertRaises(WebSocketError): yield self.ws_connect("/non_ws") + @gen_test + def test_websocket_http_redirect(self): + with self.assertRaises(HTTPError): + yield self.ws_connect("/redirect") + @gen_test def test_websocket_network_fail(self): sock, port = bind_unused_port()