MCPcopy Create free account
hub / github.com/anomalyco/opencode-sdk-python / test_optional_list

Function test_optional_list

tests/test_models.py:203–219  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

201
202
203def test_optional_list() -> None:
204 class Submodel(BaseModel):
205 name: str
206
207 class Model(BaseModel):
208 items: Optional[List[Submodel]]
209
210 m = Model.construct(items=None)
211 assert m.items is None
212
213 m = Model.construct(items=[])
214 assert m.items == []
215
216 m = Model.construct(items=[{"name": "Robert"}])
217 assert m.items is not None
218 assert len(m.items) == 1
219 assert m.items[0].name == "Robert"
220
221
222def test_nested_union_of_models() -> None:

Callers

nothing calls this directly

Calls 1

constructMethod · 0.45

Tested by

no test coverage detected