From b3ccb7b964134915853e81a52478c0768cb0ab79 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sat, 21 Jun 2014 14:05:49 -0400 Subject: [PATCH] Update tests after the removal of get_error_html. --- tornado/test/stack_context_test.py | 8 ++++---- tornado/test/web_test.py | 25 ------------------------- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/tornado/test/stack_context_test.py b/tornado/test/stack_context_test.py index d65a5b21..853260e3 100644 --- a/tornado/test/stack_context_test.py +++ b/tornado/test/stack_context_test.py @@ -35,11 +35,11 @@ class TestRequestHandler(RequestHandler): logging.debug('in part3()') raise Exception('test exception') - def get_error_html(self, status_code, **kwargs): - if 'exception' in kwargs and str(kwargs['exception']) == 'test exception': - return 'got expected exception' + def write_error(self, status_code, **kwargs): + if 'exc_info' in kwargs and str(kwargs['exc_info'][1]) == 'test exception': + self.write('got expected exception') else: - return 'unexpected failure' + self.write('unexpected failure') class HTTPStackContextTest(AsyncHTTPTestCase): diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index b32a0326..15b2fb5f 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -773,20 +773,6 @@ class ErrorResponseTest(WebTestCase): else: self.write("Status: %d" % status_code) - class GetErrorHtmlHandler(RequestHandler): - def get(self): - if self.get_argument("status", None): - self.send_error(int(self.get_argument("status"))) - else: - 1 / 0 - - def get_error_html(self, status_code, **kwargs): - self.set_header("Content-Type", "text/plain") - if "exception" in kwargs: - self.write("Exception: %s" % sys.exc_info()[0].__name__) - else: - self.write("Status: %d" % status_code) - class FailedWriteErrorHandler(RequestHandler): def get(self): 1 / 0 @@ -796,7 +782,6 @@ class ErrorResponseTest(WebTestCase): return [url("/default", DefaultHandler), url("/write_error", WriteErrorHandler), - url("/get_error_html", GetErrorHtmlHandler), url("/failed_write_error", FailedWriteErrorHandler), ] @@ -820,16 +805,6 @@ class ErrorResponseTest(WebTestCase): self.assertEqual(response.code, 503) self.assertEqual(b"Status: 503", response.body) - def test_get_error_html(self): - with ExpectLog(app_log, "Uncaught exception"): - response = self.fetch("/get_error_html") - self.assertEqual(response.code, 500) - self.assertEqual(b"Exception: ZeroDivisionError", response.body) - - response = self.fetch("/get_error_html?status=503") - self.assertEqual(response.code, 503) - self.assertEqual(b"Status: 503", response.body) - def test_failed_write_error(self): with ExpectLog(app_log, "Uncaught exception"): response = self.fetch("/failed_write_error")