예제 #1
0
파일: test_app.py 프로젝트: pgjones/quart
async def test_propagation(debug: bool, testing: bool, raises: bool,
                           http_scope: HTTPScope) -> None:
    app = Quart(__name__)

    @app.route("/")
    async def exception() -> ResponseReturnValue:
        raise SimpleError()

    app.debug = debug
    app.testing = testing
    test_client = app.test_client()

    if raises:
        with pytest.raises(SimpleError):
            await app.handle_request(
                Request(
                    "GET",
                    "http",
                    "/",
                    b"",
                    Headers(),
                    "",
                    "1.1",
                    http_scope,
                    send_push_promise=no_op_push,
                ))
    else:
        response = await test_client.get("/")
        assert response.status_code == 500
예제 #2
0
async def test_propagation(debug: bool, testing: bool, raises: bool) -> None:
    app = Quart(__name__)

    @app.route("/")
    async def exception() -> ResponseReturnValue:
        raise SimpleException()

    app.debug = debug
    app.testing = testing
    test_client = app.test_client()

    if raises:
        with pytest.raises(SimpleException):
            await test_client.get("/")
    else:
        response = await test_client.get("/")
        assert response.status_code == 500