MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / test_extra_properties

Function test_extra_properties

tests/test_models.py:1054–1077  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1052
1053@pytest.mark.skipif(PYDANTIC_V1, reason="this is only supported in pydantic v2 for now")
1054def test_extra_properties() -> None:
1055 class Item(BaseModel):
1056 prop: int
1057
1058 class Model(BaseModel):
1059 __pydantic_extra__: Dict[str, Item] = Field(init=False) # pyright: ignore[reportIncompatibleVariableOverride]
1060
1061 other: str
1062
1063 if TYPE_CHECKING:
1064
1065 def __getattr__(self, attr: str) -> Item: ...
1066
1067 model = construct_type(
1068 type_=Model,
1069 value={
1070 "a": {"prop": 1},
1071 "other": "foo",
1072 },
1073 )
1074 assert isinstance(model, Model)
1075 assert model.a.prop == 1
1076 assert isinstance(model.a, Item)
1077 assert model.other == "foo"
1078
1079
1080# NOTE: Workaround for Pydantic Iterable behavior.

Callers

nothing calls this directly

Calls 1

construct_typeFunction · 0.90

Tested by

no test coverage detected