message_test.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:Vector-Tiles-Reader-QGIS-Plugin 作者: geometalab 项目源码 文件源码
def testPickleIncompleteProto(self):
    golden_message = unittest_pb2.TestRequired(a=1)
    pickled_message = pickle.dumps(golden_message)

    unpickled_message = pickle.loads(pickled_message)
    self.assertEqual(unpickled_message, golden_message)
    self.assertEqual(unpickled_message.a, 1)
    # This is still an incomplete proto - so serializing should fail
    self.assertRaises(message.EncodeError, unpickled_message.SerializeToString)


  # TODO(haberman): this isn't really a proto2-specific test except that this
  # message has a required field in it.  Should probably be factored out so
  # that we can test the other parts with proto3.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号