From dcb23eee4eeaaa37f14475dfbf69b33e4e495870 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Mon, 17 Feb 2020 16:03:43 -0500 Subject: [PATCH] httpclient_test: Improve error reporting Without this try/finally, if this test ever fails, errors can be reported in a confusing way. --- tornado/test/httpclient_test.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tornado/test/httpclient_test.py b/tornado/test/httpclient_test.py index 7b2a43c54..a3233d2b2 100644 --- a/tornado/test/httpclient_test.py +++ b/tornado/test/httpclient_test.py @@ -500,10 +500,12 @@ X-XSS-Protection: 1; stream.close() netutil.add_accept_handler(sock, accept_callback) # type: ignore - resp = self.fetch("http://127.0.0.1:%d/" % port) - resp.rethrow() - self.assertEqual(resp.headers["X-XSS-Protection"], "1; mode=block") - self.io_loop.remove_handler(sock.fileno()) + try: + resp = self.fetch("http://127.0.0.1:%d/" % port) + resp.rethrow() + self.assertEqual(resp.headers["X-XSS-Protection"], "1; mode=block") + finally: + self.io_loop.remove_handler(sock.fileno()) def test_304_with_content_length(self): # According to the spec 304 responses SHOULD NOT include -- 2.47.2