MCPcopy
hub / github.com/pydantic/pydantic / test_init_var_field

Function test_init_var_field

tests/test_fields.py:54–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

52
53
54def test_init_var_field():
55 @pydantic.dataclasses.dataclass
56 class Foo:
57 bar: str
58 baz: str = Field(init_var=True)
59
60 class Model(BaseModel):
61 foo: Foo
62
63 model = Model(foo=Foo('bar', baz='baz'))
64 assert 'bar' in model.foo.__pydantic_fields__
65 assert 'baz' not in model.foo.__pydantic_fields__
66
67
68def test_root_model_arbitrary_field_name_error():

Callers

nothing calls this directly

Calls 2

ModelClass · 0.70
FooClass · 0.70

Tested by

no test coverage detected