Coverage for tests/serializers/pydantic/test_compat.py: 100%
11 statements
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-13 05:19 +0000
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-13 05:19 +0000
1from typing import Any 1klabmcndoefghij
3from pydantic import BaseModel 1klabmcndoefghij
5from fast_depends.pydantic._compat import get_model_fields 1klabmcndoefghij
6from tests.marks import pydanticV2 1klabmcndoefghij
9class Model(BaseModel): 1klabmcndoefghij
10 a: int 1klabmcndoe
13@pydanticV2 1klabmcndoefghij
14def test_get_model_fields_falls_back_to_model_fields() -> None: 1klabmcndoefghij
15 """Pydantic < 2.11 exposes no `__pydantic_fields__`, only the (now deprecated)
16 `model_fields` attribute.
17 """
19 class WithoutPydanticFields: 1abcdefghij
20 model_fields: dict[str, Any] = dict(get_model_fields(Model)) 1abcdefghij
22 assert get_model_fields(WithoutPydanticFields) == ( # type: ignore[arg-type] 1abcdefghij
23 WithoutPydanticFields.model_fields
24 )