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

Function test_optional_list

tests/test_models.py:218–234  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

216
217
218def test_optional_list() -> None:
219 class Submodel(BaseModel):
220 name: str
221
222 class Model(BaseModel):
223 items: Optional[List[Submodel]]
224
225 m = Model.construct(items=None)
226 assert m.items is None
227
228 m = Model.construct(items=[])
229 assert m.items == []
230
231 m = Model.construct(items=[{"name": "Robert"}])
232 assert m.items is not None
233 assert len(m.items) == 1
234 assert m.items[0].name == "Robert"
235
236
237def test_nested_union_of_models() -> None:

Callers

nothing calls this directly

Calls 1

constructMethod · 0.45

Tested by

no test coverage detected