| OLD | NEW |
| 1 #! /usr/bin/env python | 1 #! /usr/bin/env python |
| 2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
| 3 # | 3 # |
| 4 # Protocol Buffers - Google's data interchange format | 4 # Protocol Buffers - Google's data interchange format |
| 5 # Copyright 2008 Google Inc. All rights reserved. | 5 # Copyright 2008 Google Inc. All rights reserved. |
| 6 # https://developers.google.com/protocol-buffers/ | 6 # https://developers.google.com/protocol-buffers/ |
| 7 # | 7 # |
| 8 # Redistribution and use in source and binary forms, with or without | 8 # Redistribution and use in source and binary forms, with or without |
| 9 # modification, are permitted provided that the following conditions are | 9 # modification, are permitted provided that the following conditions are |
| 10 # met: | 10 # met: |
| (...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 | 965 |
| 966 # Test clearing. | 966 # Test clearing. |
| 967 proto.ClearField('repeated_nested_message') | 967 proto.ClearField('repeated_nested_message') |
| 968 self.assertTrue(not proto.repeated_nested_message) | 968 self.assertTrue(not proto.repeated_nested_message) |
| 969 self.assertEqual(0, len(proto.repeated_nested_message)) | 969 self.assertEqual(0, len(proto.repeated_nested_message)) |
| 970 | 970 |
| 971 # Test constructing an element while adding it. | 971 # Test constructing an element while adding it. |
| 972 proto.repeated_nested_message.add(bb=23) | 972 proto.repeated_nested_message.add(bb=23) |
| 973 self.assertEqual(1, len(proto.repeated_nested_message)) | 973 self.assertEqual(1, len(proto.repeated_nested_message)) |
| 974 self.assertEqual(23, proto.repeated_nested_message[0].bb) | 974 self.assertEqual(23, proto.repeated_nested_message[0].bb) |
| 975 self.assertRaises(TypeError, proto.repeated_nested_message.add, 23) |
| 975 | 976 |
| 976 def testRepeatedCompositeRemove(self): | 977 def testRepeatedCompositeRemove(self): |
| 977 proto = unittest_pb2.TestAllTypes() | 978 proto = unittest_pb2.TestAllTypes() |
| 978 | 979 |
| 979 self.assertEqual(0, len(proto.repeated_nested_message)) | 980 self.assertEqual(0, len(proto.repeated_nested_message)) |
| 980 m0 = proto.repeated_nested_message.add() | 981 m0 = proto.repeated_nested_message.add() |
| 981 # Need to set some differentiating variable so m0 != m1 != m2: | 982 # Need to set some differentiating variable so m0 != m1 != m2: |
| 982 m0.bb = len(proto.repeated_nested_message) | 983 m0.bb = len(proto.repeated_nested_message) |
| 983 m1 = proto.repeated_nested_message.add() | 984 m1 = proto.repeated_nested_message.add() |
| 984 m1.bb = len(proto.repeated_nested_message) | 985 m1.bb = len(proto.repeated_nested_message) |
| (...skipping 1989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2974 'bar {' | 2975 'bar {' |
| 2975 ' baz {' | 2976 ' baz {' |
| 2976 ' deep: 4' | 2977 ' deep: 4' |
| 2977 ' }' | 2978 ' }' |
| 2978 '}') | 2979 '}') |
| 2979 text_format.Merge(msg_str, msg) | 2980 text_format.Merge(msg_str, msg) |
| 2980 self.assertEqual(msg.bar.baz.deep, 4) | 2981 self.assertEqual(msg.bar.baz.deep, 4) |
| 2981 | 2982 |
| 2982 if __name__ == '__main__': | 2983 if __name__ == '__main__': |
| 2983 unittest.main() | 2984 unittest.main() |
| OLD | NEW |