Browse Source

Black

pull/10223/head
chbndrhnns 2 years ago
parent
commit
b72c7f04d6
  1. 32
      tests/test_pydantic_v1_models.py

32
tests/test_pydantic_v1_models.py

@ -1,23 +1,37 @@
import pytest import pytest
from fastapi import Body, FastAPI from fastapi import Body, FastAPI
from fastapi._compat import PYDANTIC_V2
from fastapi.exceptions import ResponseValidationError from fastapi.exceptions import ResponseValidationError
from fastapi.testclient import TestClient from fastapi.testclient import TestClient
from pydantic import v1
from typing_extensions import Annotated from typing_extensions import Annotated
from tests.utils import needs_pydanticv2 from tests.utils import needs_pydanticv2
if PYDANTIC_V2:
from pydantic import v1
class Item(v1.BaseModel): class Item(v1.BaseModel):
name: str name: str
description: str | None = None description: str | None = None
price: float price: float
tax: float | None = None tax: float | None = None
tags: list = [] tags: list = []
class Model(v1.BaseModel):
name: str
class Model(v1.BaseModel): else:
name: str 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() app = FastAPI()

Loading…
Cancel
Save