From 292f8fd618befb8cfbf7c307f50a25b19f9e4b77 Mon Sep 17 00:00:00 2001 From: moijes12 Date: Sun, 4 May 2014 23:52:05 +0530 Subject: [PATCH] Changed tornado/simple_httpclient.py to raise the error instead of storing the error message and then raising an HTTPError. Changed the websocket tests for network_fail and network timeout to expect an IOError instead of an HTTPError. --- tornado/simple_httpclient.py | 2 +- tornado/test/websocket_test.py | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/tornado/simple_httpclient.py b/tornado/simple_httpclient.py index c7e6f1a94..d5b980611 100644 --- a/tornado/simple_httpclient.py +++ b/tornado/simple_httpclient.py @@ -371,7 +371,7 @@ class _HTTPConnection(object): if self.final_callback is not None: message = "Connection closed" if self.stream.error: - message = str(self.stream.error) + raise self.stream.error raise HTTPError(599, message) def _handle_1xx(self, code): diff --git a/tornado/test/websocket_test.py b/tornado/test/websocket_test.py index e45066536..648e5d8ca 100644 --- a/tornado/test/websocket_test.py +++ b/tornado/test/websocket_test.py @@ -114,25 +114,23 @@ class WebSocketTest(AsyncHTTPTestCase): def test_websocket_network_timeout(self): sock, port = bind_unused_port() sock.close() - with self.assertRaises(HTTPError) as cm: + with self.assertRaises(IOError) as cm: with ExpectLog(gen_log, ".*"): yield websocket_connect( 'ws://localhost:%d/' % port, io_loop=self.io_loop, connect_timeout=0.01) - self.assertEqual(cm.exception.code, 599) @gen_test def test_websocket_network_fail(self): sock, port = bind_unused_port() sock.close() - with self.assertRaises(HTTPError) as cm: + with self.assertRaises(IOError) as cm: with ExpectLog(gen_log, ".*"): yield websocket_connect( 'ws://localhost:%d/' % port, io_loop=self.io_loop, connect_timeout=3600) - self.assertEqual(cm.exception.code, 599) @gen_test def test_websocket_close_buffered_data(self): -- 2.47.2