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