Coverage for tests/test_response_model_invalid.py: 100%
26 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
1from typing import List 1abcde
3import pytest 1abcde
4from fastapi import FastAPI 1abcde
5from fastapi.exceptions import FastAPIError 1abcde
8class NonPydanticModel: 1abcde
9 pass 1abcde
12def test_invalid_response_model_raises(): 1abcde
13 with pytest.raises(FastAPIError): 1abcde
14 app = FastAPI() 1abcde
16 @app.get("/", response_model=NonPydanticModel) 1abcde
17 def read_root(): 1abcde
18 pass # pragma: nocover
21def test_invalid_response_model_sub_type_raises(): 1abcde
22 with pytest.raises(FastAPIError): 1abcde
23 app = FastAPI() 1abcde
25 @app.get("/", response_model=List[NonPydanticModel]) 1abcde
26 def read_root(): 1abcde
27 pass # pragma: nocover
30def test_invalid_response_model_in_responses_raises(): 1abcde
31 with pytest.raises(FastAPIError): 1abcde
32 app = FastAPI() 1abcde
34 @app.get("/", responses={"500": {"model": NonPydanticModel}}) 1abcde
35 def read_root(): 1abcde
36 pass # pragma: nocover
39def test_invalid_response_model_sub_type_in_responses_raises(): 1abcde
40 with pytest.raises(FastAPIError): 1abcde
41 app = FastAPI() 1abcde
43 @app.get("/", responses={"500": {"model": List[NonPydanticModel]}}) 1abcde
44 def read_root(): 1abcde
45 pass # pragma: nocover