| OLD | NEW |
| 1 #! /usr/bin/env python | 1 #! /usr/bin/env python |
| 2 # | 2 # |
| 3 # Protocol Buffers - Google's data interchange format | 3 # Protocol Buffers - Google's data interchange format |
| 4 # Copyright 2008 Google Inc. All rights reserved. | 4 # Copyright 2008 Google Inc. All rights reserved. |
| 5 # https://developers.google.com/protocol-buffers/ | 5 # https://developers.google.com/protocol-buffers/ |
| 6 # | 6 # |
| 7 # Redistribution and use in source and binary forms, with or without | 7 # Redistribution and use in source and binary forms, with or without |
| 8 # modification, are permitted provided that the following conditions are | 8 # modification, are permitted provided that the following conditions are |
| 9 # met: | 9 # met: |
| 10 # | 10 # |
| (...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 msg.map_int32_int32[12] = 34 | 1428 msg.map_int32_int32[12] = 34 |
| 1429 msg.map_int32_int32[56] = 78 | 1429 msg.map_int32_int32[56] = 78 |
| 1430 msg.map_int64_int64[22] = 33 | 1430 msg.map_int64_int64[22] = 33 |
| 1431 msg.map_int32_foreign_message[111].c = 5 | 1431 msg.map_int32_foreign_message[111].c = 5 |
| 1432 msg.map_int32_foreign_message[222].c = 10 | 1432 msg.map_int32_foreign_message[222].c = 10 |
| 1433 | 1433 |
| 1434 msg2 = map_unittest_pb2.TestMap() | 1434 msg2 = map_unittest_pb2.TestMap() |
| 1435 msg2.map_int32_int32[12] = 55 | 1435 msg2.map_int32_int32[12] = 55 |
| 1436 msg2.map_int64_int64[88] = 99 | 1436 msg2.map_int64_int64[88] = 99 |
| 1437 msg2.map_int32_foreign_message[222].c = 15 | 1437 msg2.map_int32_foreign_message[222].c = 15 |
| 1438 msg2.map_int32_foreign_message[222].d = 20 |
| 1439 old_map_value = msg2.map_int32_foreign_message[222] |
| 1438 | 1440 |
| 1439 msg2.MergeFrom(msg) | 1441 msg2.MergeFrom(msg) |
| 1440 | 1442 |
| 1441 self.assertEqual(34, msg2.map_int32_int32[12]) | 1443 self.assertEqual(34, msg2.map_int32_int32[12]) |
| 1442 self.assertEqual(78, msg2.map_int32_int32[56]) | 1444 self.assertEqual(78, msg2.map_int32_int32[56]) |
| 1443 self.assertEqual(33, msg2.map_int64_int64[22]) | 1445 self.assertEqual(33, msg2.map_int64_int64[22]) |
| 1444 self.assertEqual(99, msg2.map_int64_int64[88]) | 1446 self.assertEqual(99, msg2.map_int64_int64[88]) |
| 1445 self.assertEqual(5, msg2.map_int32_foreign_message[111].c) | 1447 self.assertEqual(5, msg2.map_int32_foreign_message[111].c) |
| 1446 self.assertEqual(10, msg2.map_int32_foreign_message[222].c) | 1448 self.assertEqual(10, msg2.map_int32_foreign_message[222].c) |
| 1449 self.assertFalse(msg2.map_int32_foreign_message[222].HasField('d')) |
| 1450 self.assertEqual(15, old_map_value.c) |
| 1447 | 1451 |
| 1448 # Verify that there is only one entry per key, even though the MergeFrom | 1452 # Verify that there is only one entry per key, even though the MergeFrom |
| 1449 # may have internally created multiple entries for a single key in the | 1453 # may have internally created multiple entries for a single key in the |
| 1450 # list representation. | 1454 # list representation. |
| 1451 as_dict = {} | 1455 as_dict = {} |
| 1452 for key in msg2.map_int32_foreign_message: | 1456 for key in msg2.map_int32_foreign_message: |
| 1453 self.assertFalse(key in as_dict) | 1457 self.assertFalse(key in as_dict) |
| 1454 as_dict[key] = msg2.map_int32_foreign_message[key].c | 1458 as_dict[key] = msg2.map_int32_foreign_message[key].c |
| 1455 | 1459 |
| 1456 self.assertEqual({111: 5, 222: 10}, as_dict) | 1460 self.assertEqual({111: 5, 222: 10}, as_dict) |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1843 | 1847 |
| 1844 def testSucceedOversizeProto(self): | 1848 def testSucceedOversizeProto(self): |
| 1845 from google.protobuf.pyext._message import SetAllowOversizeProtos | 1849 from google.protobuf.pyext._message import SetAllowOversizeProtos |
| 1846 SetAllowOversizeProtos(True) | 1850 SetAllowOversizeProtos(True) |
| 1847 q = self.proto_cls() | 1851 q = self.proto_cls() |
| 1848 q.ParseFromString(self.p_serialized) | 1852 q.ParseFromString(self.p_serialized) |
| 1849 self.assertEqual(self.p.field.payload, q.field.payload) | 1853 self.assertEqual(self.p.field.payload, q.field.payload) |
| 1850 | 1854 |
| 1851 if __name__ == '__main__': | 1855 if __name__ == '__main__': |
| 1852 unittest.main() | 1856 unittest.main() |
| OLD | NEW |