Coverage for tests/test_invalid_path_param.py: 100%
45 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-12-04 08:29 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-12-04 08:29 +0000
1from typing import Dict, List, Tuple 1abcdefg
3import pytest 1abcdefg
4from fastapi import FastAPI 1abcdefg
5from pydantic import BaseModel 1abcdefg
8def test_invalid_sequence(): 1abcdefg
9 with pytest.raises(AssertionError): 1hijklmn
10 app = FastAPI() 1hijklmn
12 class Item(BaseModel): 1hijklmn
13 title: str 1hijklmn
15 @app.get("/items/{id}") 1hijklmn
16 def read_items(id: List[Item]): 1hijklmn
17 pass # pragma: no cover
20def test_invalid_tuple(): 1abcdefg
21 with pytest.raises(AssertionError): 1opqrstu
22 app = FastAPI() 1opqrstu
24 class Item(BaseModel): 1opqrstu
25 title: str 1opqrstu
27 @app.get("/items/{id}") 1opqrstu
28 def read_items(id: Tuple[Item, Item]): 1opqrstu
29 pass # pragma: no cover
32def test_invalid_dict(): 1abcdefg
33 with pytest.raises(AssertionError): 1vwxyzAB
34 app = FastAPI() 1vwxyzAB
36 class Item(BaseModel): 1vwxyzAB
37 title: str 1vwxyzAB
39 @app.get("/items/{id}") 1vwxyzAB
40 def read_items(id: Dict[str, Item]): 1vwxyzAB
41 pass # pragma: no cover
44def test_invalid_simple_list(): 1abcdefg
45 with pytest.raises(AssertionError): 1CDEFGHI
46 app = FastAPI() 1CDEFGHI
48 @app.get("/items/{id}") 1CDEFGHI
49 def read_items(id: list): 1CDEFGHI
50 pass # pragma: no cover
53def test_invalid_simple_tuple(): 1abcdefg
54 with pytest.raises(AssertionError): 1JKLMNOP
55 app = FastAPI() 1JKLMNOP
57 @app.get("/items/{id}") 1JKLMNOP
58 def read_items(id: tuple): 1JKLMNOP
59 pass # pragma: no cover
62def test_invalid_simple_set(): 1abcdefg
63 with pytest.raises(AssertionError): 1QRSTUVW
64 app = FastAPI() 1QRSTUVW
66 @app.get("/items/{id}") 1QRSTUVW
67 def read_items(id: set): 1QRSTUVW
68 pass # pragma: no cover
71def test_invalid_simple_dict(): 1abcdefg
72 with pytest.raises(AssertionError): 1XYZ0123
73 app = FastAPI() 1XYZ0123
75 @app.get("/items/{id}") 1XYZ0123
76 def read_items(id: dict): 1XYZ0123
77 pass # pragma: no cover