]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Changed tornado/simple_httpclient.py to raise the error instead of 1042/head
authormoijes12 <moijes12@gmail.com>
Sun, 4 May 2014 18:22:05 +0000 (23:52 +0530)
committermoijes12 <moijes12@gmail.com>
Sun, 4 May 2014 18:22:05 +0000 (23:52 +0530)
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
tornado/test/websocket_test.py

index c7e6f1a940f3c38c4f6fcd6ed728971ae3696852..d5b980611627a6fba08ce951afaf8f4b3f1a2e71 100644 (file)
@@ -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):
index e45066536d8dc81315f59300bc53f837fb1622f8..648e5d8ca2612b58add0fb35546c9bb18137e8ef 100644 (file)
@@ -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):