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

Function test_unknown_fields

tests/test_features.py:116–135  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

114
115
116def test_unknown_fields():
117 @dataclass
118 class Newer(betterproto.Message):
119 foo: bool = betterproto.bool_field(1)
120 bar: int = betterproto.int32_field(2)
121 baz: str = betterproto.string_field(3)
122
123 @dataclass
124 class Older(betterproto.Message):
125 foo: bool = betterproto.bool_field(1)
126
127 newer = Newer(foo=True, bar=1, baz="Hello")
128 serialized_newer = bytes(newer)
129
130 # Unknown fields in `Newer` should round trip with `Older`
131 round_trip = bytes(Older().parse(serialized_newer))
132 assert serialized_newer == round_trip
133
134 new_again = Newer().parse(round_trip)
135 assert newer == new_again
136
137
138def test_oneof_support():

Callers

nothing calls this directly

Calls 3

NewerClass · 0.85
OlderClass · 0.85
parseMethod · 0.80

Tested by

no test coverage detected