Coverage for tests / test_invalid_path_param.py: 100%
44 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
1import pytest 1abcd
2from fastapi import FastAPI 1abcd
3from pydantic import BaseModel 1abcd
6def test_invalid_sequence(): 1abcd
7 with pytest.raises(AssertionError): 1efg
8 app = FastAPI() 1efg
10 class Item(BaseModel): 1efg
11 title: str 1efg
13 @app.get("/items/{id}") 1efg
14 def read_items(id: list[Item]): 1efg
15 pass # pragma: no cover
18def test_invalid_tuple(): 1abcd
19 with pytest.raises(AssertionError): 1hij
20 app = FastAPI() 1hij
22 class Item(BaseModel): 1hij
23 title: str 1hij
25 @app.get("/items/{id}") 1hij
26 def read_items(id: tuple[Item, Item]): 1hij
27 pass # pragma: no cover
30def test_invalid_dict(): 1abcd
31 with pytest.raises(AssertionError): 1klm
32 app = FastAPI() 1klm
34 class Item(BaseModel): 1klm
35 title: str 1klm
37 @app.get("/items/{id}") 1klm
38 def read_items(id: dict[str, Item]): 1klm
39 pass # pragma: no cover
42def test_invalid_simple_list(): 1abcd
43 with pytest.raises(AssertionError): 1nop
44 app = FastAPI() 1nop
46 @app.get("/items/{id}") 1nop
47 def read_items(id: list): 1nop
48 pass # pragma: no cover
51def test_invalid_simple_tuple(): 1abcd
52 with pytest.raises(AssertionError): 1qrs
53 app = FastAPI() 1qrs
55 @app.get("/items/{id}") 1qrs
56 def read_items(id: tuple): 1qrs
57 pass # pragma: no cover
60def test_invalid_simple_set(): 1abcd
61 with pytest.raises(AssertionError): 1tuv
62 app = FastAPI() 1tuv
64 @app.get("/items/{id}") 1tuv
65 def read_items(id: set): 1tuv
66 pass # pragma: no cover
69def test_invalid_simple_dict(): 1abcd
70 with pytest.raises(AssertionError): 1wxy
71 app = FastAPI() 1wxy
73 @app.get("/items/{id}") 1wxy
74 def read_items(id: dict): 1wxy
75 pass # pragma: no cover