Skip to content

Commit

Permalink
fix: fixes bug in the test. (#332)
Browse files Browse the repository at this point in the history
* fix: fixes bug in the test.
  • Loading branch information
atulep authored Aug 4, 2022
1 parent 02ddf17 commit f85f470
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
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}

0 comments on commit f85f470

Please sign in to comment.