Skip to content

Commit

Permalink
websocket_test: test websocket_connect redirect raises exception
Browse files Browse the repository at this point in the history
instead of "uncaught exception" and then test timeout
  • Loading branch information
ploxiln committed Sep 25, 2020
1 parent 94f155d commit 79c6056
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tornado/test/websocket_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 79c6056

Please sign in to comment.