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

Function test_extra_properties

tests/test_models.py:1035–1058  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1033
1034@pytest.mark.skipif(PYDANTIC_V1, reason="this is only supported in pydantic v2 for now")
1035def test_extra_properties() -> None:
1036 class Item(BaseModel):
1037 prop: int
1038
1039 class Model(BaseModel):
1040 __pydantic_extra__: Dict[str, Item] = Field(init=False) # pyright: ignore[reportIncompatibleVariableOverride]
1041
1042 other: str
1043
1044 if TYPE_CHECKING:
1045
1046 def __getattr__(self, attr: str) -> Item: ...
1047
1048 model = construct_type(
1049 type_=Model,
1050 value={
1051 "a": {"prop": 1},
1052 "other": "foo",
1053 },
1054 )
1055 assert isinstance(model, Model)
1056 assert model.a.prop == 1
1057 assert isinstance(model.a, Item)
1058 assert model.other == "foo"
1059
1060
1061# NOTE: Workaround for Pydantic Iterable behavior.

Callers

nothing calls this directly

Calls 1

construct_typeFunction · 0.90

Tested by

no test coverage detected