MCPcopy
hub / github.com/openai/openai-python / test_iterable_construction

Function test_iterable_construction

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

Source from the content-addressed store, hash-verified

985)
986@pytest.mark.skipif(PYDANTIC_V1, reason="this is only supported in pydantic v2")
987def test_iterable_construction(data: Iterable[int], expected_validated: Iterable[int]) -> None:
988 class TypeWithIterable(TypedDict):
989 items: EagerIterable[int]
990
991 class Model(BaseModel):
992 data: TypeWithIterable
993
994 m = Model.model_validate({"data": {"items": data}})
995 assert m.data["items"] == expected_validated
996
997 # Verify repeated dumps don't lose data (the original bug)
998 assert m.model_dump()["data"]["items"] == list(expected_validated)
999 assert m.model_dump()["data"]["items"] == list(expected_validated)
1000
1001
1002@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