def test_HtmlHandler_handle_exception(app):
    """HTMLHandler passes regular exceptions through to the caller"""
    h = api.HtmlHandler()
    with app.test_request_context():
        try:
            raise RuntimeError("oh noes")
        except Exception:
            # just passes through regular exceptions
            assert_raises(RuntimeError,
                          lambda: h.handle_exception(*sys.exc_info()))
def test_HtmlHandler_handle_exception_httpexception(app):
    """HTMLHandler passes HTTP exceptions to app.handle_http_exception"""
    h = api.HtmlHandler()
    with app.test_request_context():
        with mock.patch("flask.current_app.handle_http_exception") as hhe:
            br = BadRequest()
            try:
                raise br
            except Exception:
                h.handle_exception(*sys.exc_info())
            hhe.assert_called_with(br)
def test_HtmlHandler_render_response(app):
    h = api.HtmlHandler()
    with app.test_request_context():
        resp = h.render_response([1, 2, 3], 200, {})
        assert '<html' in resp.data, resp.data
        assert "1," in resp.data, resp.data