示例#1
0
def application(environ: Dict[str, Any], start_response: 'StartResponse',
                ctx: context.Context) -> Iterable[bytes]:
    """The entry point of this WSGI app."""
    ret, err = our_application(environ, start_response, ctx)
    if err:
        return webframe.handle_exception(environ, start_response, err)
    return ret
示例#2
0
def application(environ: Dict[str, Any],
                start_response: 'StartResponse') -> Iterable[bytes]:
    """The entry point of this WSGI app."""
    try:
        return our_application(environ, start_response)

    # pylint: disable=broad-except
    except Exception:
        return webframe.handle_exception(environ, start_response)
示例#3
0
    def test_happy(self) -> None:
        """Tests the happy path."""
        environ = {"PATH_INFO": "/"}

        def start_response(status: str,
                           response_headers: List[Tuple[str, str]]) -> None:
            self.assertTrue(status.startswith("500"))
            header_dict = dict(response_headers)
            self.assertEqual(header_dict["Content-type"],
                             "text/html; charset=utf-8")

        try:
            int("a")
        # pylint: disable=broad-except
        except Exception:
            callback = cast('StartResponse', start_response)
            output_iterable = webframe.handle_exception(environ, callback)
            output_list = cast(List[bytes], output_iterable)
            self.assertTrue(output_list)
            output = output_list[0].decode('utf-8')
            self.assertIn("ValueError", output)
            return
        self.fail()