def testEmptyDescriptorPool(self):
# Check that an empty DescriptorPool() contains no messages.
pool = descriptor_pool.DescriptorPool()
proto_file_name = descriptor_pb2.DESCRIPTOR.name
self.assertRaises(KeyError, pool.FindFileByName, proto_file_name)
# Add the above file to the pool
file_descriptor = descriptor_pb2.FileDescriptorProto()
descriptor_pb2.DESCRIPTOR.CopyToProto(file_descriptor)
pool.Add(file_descriptor)
# Now it exists.
self.assertTrue(pool.FindFileByName(proto_file_name))
descriptor_pool_test.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录