Fix serialization of repeated fields with empty messages (#180)

Extend test config and utils to support exclusion of certain json samples from
testing for symetry.
This commit is contained in:
nat
2021-04-06 02:50:45 +02:00
committed by GitHub
parent deb623ed14
commit 7368299a70
8 changed files with 78 additions and 25 deletions

View File

@@ -739,9 +739,18 @@ class Message(ABC):
output += _serialize_single(meta.number, TYPE_BYTES, buf)
else:
for item in value:
output += _serialize_single(
meta.number, meta.proto_type, item, wraps=meta.wraps or ""
output += (
_serialize_single(
meta.number,
meta.proto_type,
item,
wraps=meta.wraps or "",
)
# if it's an empty message it still needs to be represented
# as an item in the repeated list
or b"\n\x00"
)
elif isinstance(value, dict):
for k, v in value.items():
assert meta.map_types