File: test_exceptions.py

package info (click to toggle)
quart 0.20.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,892 kB
  • sloc: python: 8,644; makefile: 42; sh: 17; sql: 6
file content (22 lines) | stat: -rw-r--r-- 635 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from __future__ import annotations

from http import HTTPStatus

import pytest
from werkzeug.exceptions import abort
from werkzeug.exceptions import HTTPException

from quart import Response


@pytest.mark.parametrize("status", [400, HTTPStatus.BAD_REQUEST])
def test_abort(status: int | HTTPStatus) -> None:
    with pytest.raises(HTTPException) as exc_info:
        abort(status)
    assert exc_info.value.get_response().status_code == 400


def test_abort_with_response() -> None:
    with pytest.raises(HTTPException) as exc_info:
        abort(Response("Message", 205))
    assert exc_info.value.get_response().status_code == 205