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

Function test_optional_nested_model

tests/test_models.py:37–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35
36
37def test_optional_nested_model() -> None:
38 class NestedModel(BaseModel):
39 nested: Optional[BasicModel]
40
41 m1 = NestedModel.construct(nested=None)
42 assert m1.nested is None
43
44 m2 = NestedModel.construct(nested={"foo": "bar"})
45 assert m2.nested is not None
46 assert m2.nested.foo == "bar"
47
48 # mismatched types
49 m3 = NestedModel.construct(nested={"foo"})
50 assert isinstance(cast(Any, m3.nested), set)
51 assert cast(Any, m3.nested) == {"foo"}
52
53
54def test_list_nested_model() -> None:

Callers

nothing calls this directly

Calls 1

constructMethod · 0.45

Tested by

no test coverage detected