From 26b75b10cc3fb9fd88f15c11a7bc70bf32e38470 Mon Sep 17 00:00:00 2001 From: Roberto Prevato Date: Fri, 3 Nov 2023 18:51:05 +0100 Subject: [PATCH] Fix assertion for new Pydantic 2 behavior --- tests/test_openapi_v3.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/tests/test_openapi_v3.py b/tests/test_openapi_v3.py index 7347440b..e1765d67 100644 --- a/tests/test_openapi_v3.py +++ b/tests/test_openapi_v3.py @@ -20,7 +20,7 @@ ValueFormat, ValueType, ) -from pydantic import VERSION, BaseModel, HttpUrl +from pydantic import VERSION as PYDANTIC_LIB_VERSION, BaseModel, HttpUrl from pydantic.types import NegativeFloat, PositiveInt, condecimal, confloat, conint from blacksheep.server.application import Application @@ -44,20 +44,13 @@ from blacksheep.server.routing import RoutesRegistry GenericModel = BaseModel + PYDANTIC_VERSION = 2 -if int(VERSION[0]) < 2: + +if int(PYDANTIC_LIB_VERSION[0]) < 2: from pydantic.generics import GenericModel PYDANTIC_VERSION = 1 -# try: -# from pydantic.generics import GenericModel -# except ImportError: -# # Pydantic v2 -# # https://docs.pydantic.dev/latest/blog/pydantic-v2/#other-improvements -# GenericModel = BaseModel -# PYDANTIC_VERSION = 2 -# else: -# PYDANTIC_VERSION = 1 try: from pydantic import field_validator @@ -212,7 +205,7 @@ class PydConstrained(BaseModel): b: NegativeFloat big_int: conint(gt=1000, lt=1024) - big_float: confloat(gt=1000, lt=1024) + big_float: confloat(gt=1000.0, lt=1024.0) unit_interval: confloat(ge=0, le=1) decimal_positive: condecimal(gt=0)