From b72c7f04d698d29c4af235c41807d72d05f156dc Mon Sep 17 00:00:00 2001 From: chbndrhnns Date: Fri, 8 Sep 2023 18:19:53 +0200 Subject: [PATCH] Black --- tests/test_pydantic_v1_models.py | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/tests/test_pydantic_v1_models.py b/tests/test_pydantic_v1_models.py index 35f0195cc..a719ee4b4 100644 --- a/tests/test_pydantic_v1_models.py +++ b/tests/test_pydantic_v1_models.py @@ -1,23 +1,37 @@ import pytest from fastapi import Body, FastAPI +from fastapi._compat import PYDANTIC_V2 from fastapi.exceptions import ResponseValidationError from fastapi.testclient import TestClient -from pydantic import v1 from typing_extensions import Annotated from tests.utils import needs_pydanticv2 +if PYDANTIC_V2: + from pydantic import v1 -class Item(v1.BaseModel): - name: str - description: str | None = None - price: float - tax: float | None = None - tags: list = [] + class Item(v1.BaseModel): + name: str + description: str | None = None + price: float + tax: float | None = None + tags: list = [] + class Model(v1.BaseModel): + name: str -class Model(v1.BaseModel): - name: str +else: + from pydantic import BaseModel + + class Item(BaseModel): + name: str + description: str | None = None + price: float + tax: float | None = None + tags: list = [] + + class Model(BaseModel): + name: str app = FastAPI()