def testExtensionSerializationDictMatchesProto3Spec(self):
    """See go/proto3-json-spec for spec.
    """
    message = unittest_mset_pb2.TestMessageSetContainer()
    ext1 = unittest_mset_pb2.TestMessageSetExtension1.message_set_extension
    ext2 = unittest_mset_pb2.TestMessageSetExtension2.message_set_extension
    message.message_set.Extensions[ext1].i = 23
    message.message_set.Extensions[ext2].str = 'foo'
    message_dict = json_format.MessageToDict(
        message
    )
    golden_dict = {
        'messageSet': {
            '[protobuf_unittest.'
            'TestMessageSetExtension1.message_set_extension]': {
                'i': 23,
            },
            '[protobuf_unittest.'
            'TestMessageSetExtension2.message_set_extension]': {
                'str': u'foo',
            },
        },
    }
    self.assertEqual(golden_dict, message_dict)
    parsed_msg = unittest_mset_pb2.TestMessageSetContainer()
    json_format.ParseDict(golden_dict, parsed_msg)
    self.assertEqual(message, parsed_msg)
See go/proto3-json-spec for spec.
    
deps/protobuf/python/google/protobuf/internal/json_format_test.py