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

Function test_iterable_construction

tests/test_models.py:1081–1093  ·  view source on GitHub ↗
(data: Iterable[int], expected_validated: Iterable[int])

Source from the content-addressed store, hash-verified

1079)
1080@pytest.mark.skipif(PYDANTIC_V1, reason="this is only supported in pydantic v2")
1081def test_iterable_construction(data: Iterable[int], expected_validated: Iterable[int]) -> None:
1082 class TypeWithIterable(TypedDict):
1083 items: EagerIterable[int]
1084
1085 class Model(BaseModel):
1086 data: TypeWithIterable
1087
1088 m = Model.model_validate({"data": {"items": data}})
1089 assert m.data["items"] == expected_validated
1090
1091 # Verify repeated dumps don't lose data (the original bug)
1092 assert m.model_dump()["data"]["items"] == list(expected_validated)
1093 assert m.model_dump()["data"]["items"] == list(expected_validated)
1094
1095
1096@pytest.mark.skipif(PYDANTIC_V1, reason="this is only supported in pydantic v2")

Callers

nothing calls this directly

Calls 1

model_dumpMethod · 0.80

Tested by

no test coverage detected