test_views.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:maas 作者: maas 项目源码 文件源码
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)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号