def test__handle_uncaught_exception_logs_other_failure(self):
handler = views.WebApplicationHandler()
request = make_request()
request.path = factory.make_name("path")
# Capture an exc_info tuple with traceback.
exc_type = factory.make_exception_type()
exc_msg = factory.make_name("message")
try:
raise exc_type(exc_msg)
except exc_type:
exc_info = sys.exc_info()
with FakeLogger(views.__name__, logging.ERROR) as logger:
handler.handle_uncaught_exception(
request=request, resolver=get_resolver(None),
exc_info=exc_info)
self.assertThat(
logger.output, DocTestMatches("""\
500 Internal Server Error @ %s
Traceback (most recent call last):
...
maastesting.factory.TestException#...: %s
""" % (request.path, exc_msg)))
评论列表
文章目录