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

Function test_nested_union_of_models

tests/test_models.py:237–249  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

235
236
237def test_nested_union_of_models() -> None:
238 class Submodel1(BaseModel):
239 bar: bool
240
241 class Submodel2(BaseModel):
242 thing: str
243
244 class Model(BaseModel):
245 foo: Union[Submodel1, Submodel2]
246
247 m = Model.construct(foo={"thing": "hello"})
248 assert isinstance(m.foo, Submodel2)
249 assert m.foo.thing == "hello"
250
251
252def test_nested_union_of_mixed_types() -> None:

Callers

nothing calls this directly

Calls 1

constructMethod · 0.45

Tested by

no test coverage detected