MCPcopy
hub / github.com/danielgtaylor/python-betterproto / test_class_init

Function test_class_init

tests/test_features.py:77–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

75
76
77def test_class_init():
78 @dataclass
79 class Bar(betterproto.Message):
80 name: str = betterproto.string_field(1)
81
82 @dataclass
83 class Foo(betterproto.Message):
84 name: str = betterproto.string_field(1)
85 child: Bar = betterproto.message_field(2)
86
87 foo = Foo(name="foo", child=Bar(name="bar"))
88
89 assert foo.to_dict() == {"name": "foo", "child": {"name": "bar"}}
90 assert foo.to_pydict() == {"name": "foo", "child": {"name": "bar"}}
91
92
93def test_enum_as_int_json():

Callers

nothing calls this directly

Calls 4

BarClass · 0.85
to_pydictMethod · 0.80
FooClass · 0.70
to_dictMethod · 0.45

Tested by

no test coverage detected