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

Function test_iterable_construction

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

Source from the content-addressed store, hash-verified

1098)
1099@pytest.mark.skipif(PYDANTIC_V1, reason="this is only supported in pydantic v2")
1100def test_iterable_construction(data: Iterable[int], expected_validated: Iterable[int]) -> None:
1101 class TypeWithIterable(TypedDict):
1102 items: EagerIterable[int]
1103
1104 class Model(BaseModel):
1105 data: TypeWithIterable
1106
1107 m = Model.model_validate({"data": {"items": data}})
1108 assert m.data["items"] == expected_validated
1109
1110 # Verify repeated dumps don't lose data (the original bug)
1111 assert m.model_dump()["data"]["items"] == list(expected_validated)
1112 assert m.model_dump()["data"]["items"] == list(expected_validated)
1113
1114
1115@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