Browse Source

Add test for coverage

pull/14609/head
Sebastián Ramírez 7 months ago
parent
commit
9cf3f31673
  1. 27
      tests/test_pydantic_v1_error.py

27
tests/test_pydantic_v1_error.py

@ -1,5 +1,6 @@
import sys
import warnings
from typing import Union
import pytest
@ -68,3 +69,29 @@ def test_raises_pydantic_v1_model_in_additional_responses_model() -> None:
)
def endpoint(): # pragma: no cover
return {"ok": True}
def test_raises_pydantic_v1_model_in_union() -> None:
class ModelV1A(BaseModel):
name: str
app = FastAPI()
with pytest.raises(PydanticV1NotSupportedError):
@app.post("/union")
def endpoint(data: Union[dict, ModelV1A]): # pragma: no cover
return data
def test_raises_pydantic_v1_model_in_sequence() -> None:
class ModelV1A(BaseModel):
name: str
app = FastAPI()
with pytest.raises(PydanticV1NotSupportedError):
@app.post("/sequence")
def endpoint(data: list[ModelV1A]): # pragma: no cover
return data

Loading…
Cancel
Save