Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixes bug in the test. #332

Merged
merged 3 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions proto/marshal/collections/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,8 @@ def __setitem__(self, key, value):
#
# Therefore, we create a key that way (clearing any fields that may
# be set) and then merge in our values.
# TODO: self.pb[key] should always be Message. Remove this after protobuf fix.
# In UPB, sometimes self.pb[key] is not always a proto.
# This happens during marshalling when the pb_value is upb.MapCompositeContainer
# so it's not marshalled correcrtly (i.e. should be scalar values not composite).
if isinstance(self.pb[key], Message):
self.pb[key].Clear()
self.pb[key].MergeFrom(pb_value)
else:
self.pb[key] = value
self.pb[key].Clear()
self.pb[key].MergeFrom(pb_value)

def __delitem__(self, key):
self.pb.pop(key)
Expand Down
3 changes: 1 addition & 2 deletions tests/test_marshal_types_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,4 @@ class MolluscContainer(proto.Message):
clam = Bivalve.CLAM
mc.bivalves["clam"] = clam
mc.bivalves["oyster"] = 1

assert mc.bivalves == {"clam": clam, "oyster": Bivalve.OYSTER}
assert dict(mc.bivalves) == {"clam": clam, "oyster": Bivalve.OYSTER}