Change to have parse
*always* set serialized_on_wire
This commit is contained in:
parent
5c700618fd
commit
28a288924f
@ -741,15 +741,15 @@ class Message(ABC):
|
||||
Parse the binary encoded Protobuf into this message instance. This
|
||||
returns the instance itself and is therefore assignable and chainable.
|
||||
"""
|
||||
# Got some data over the wire
|
||||
self._serialized_on_wire = True
|
||||
|
||||
for parsed in parse_fields(data):
|
||||
field_name = self._betterproto.field_name_by_number.get(parsed.number)
|
||||
if not field_name:
|
||||
self._unknown_fields += parsed.raw
|
||||
continue
|
||||
|
||||
# Got some data over the wire
|
||||
self._serialized_on_wire = True
|
||||
|
||||
meta = self._betterproto.meta_by_field_name[field_name]
|
||||
|
||||
value: Any
|
||||
|
@ -39,11 +39,9 @@ def test_has_field():
|
||||
2, betterproto.TYPE_STRING, betterproto.TYPE_STRING
|
||||
)
|
||||
|
||||
# Unset with empty collections
|
||||
# Is always set from parse, even if all collections are empty
|
||||
with_collections_empty = WithCollections().parse(bytes(WithCollections()))
|
||||
assert betterproto.serialized_on_wire(with_collections_empty) == False
|
||||
|
||||
# Set with non-empty collections
|
||||
assert betterproto.serialized_on_wire(with_collections_empty) == True
|
||||
with_collections_list = WithCollections().parse(
|
||||
bytes(WithCollections(test_list=["a", "b", "c"]))
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user