mirror of
https://github.com/fastapi/fastapi.git
synced 2025-12-24 06:39:31 -05:00
76 lines
1.6 KiB
Python
76 lines
1.6 KiB
Python
import pytest
|
|
from fastapi import FastAPI
|
|
from pydantic import BaseModel
|
|
|
|
|
|
def test_invalid_sequence():
|
|
with pytest.raises(AssertionError):
|
|
app = FastAPI()
|
|
|
|
class Item(BaseModel):
|
|
title: str
|
|
|
|
@app.get("/items/{id}")
|
|
def read_items(id: list[Item]):
|
|
pass # pragma: no cover
|
|
|
|
|
|
def test_invalid_tuple():
|
|
with pytest.raises(AssertionError):
|
|
app = FastAPI()
|
|
|
|
class Item(BaseModel):
|
|
title: str
|
|
|
|
@app.get("/items/{id}")
|
|
def read_items(id: tuple[Item, Item]):
|
|
pass # pragma: no cover
|
|
|
|
|
|
def test_invalid_dict():
|
|
with pytest.raises(AssertionError):
|
|
app = FastAPI()
|
|
|
|
class Item(BaseModel):
|
|
title: str
|
|
|
|
@app.get("/items/{id}")
|
|
def read_items(id: dict[str, Item]):
|
|
pass # pragma: no cover
|
|
|
|
|
|
def test_invalid_simple_list():
|
|
with pytest.raises(AssertionError):
|
|
app = FastAPI()
|
|
|
|
@app.get("/items/{id}")
|
|
def read_items(id: list):
|
|
pass # pragma: no cover
|
|
|
|
|
|
def test_invalid_simple_tuple():
|
|
with pytest.raises(AssertionError):
|
|
app = FastAPI()
|
|
|
|
@app.get("/items/{id}")
|
|
def read_items(id: tuple):
|
|
pass # pragma: no cover
|
|
|
|
|
|
def test_invalid_simple_set():
|
|
with pytest.raises(AssertionError):
|
|
app = FastAPI()
|
|
|
|
@app.get("/items/{id}")
|
|
def read_items(id: set):
|
|
pass # pragma: no cover
|
|
|
|
|
|
def test_invalid_simple_dict():
|
|
with pytest.raises(AssertionError):
|
|
app = FastAPI()
|
|
|
|
@app.get("/items/{id}")
|
|
def read_items(id: dict):
|
|
pass # pragma: no cover
|