本文整理汇总了Python中Pyro4.message.Message.data_size方法的典型用法代码示例。如果您正苦于以下问题:Python Message.data_size方法的具体用法?Python Message.data_size怎么用?Python Message.data_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pyro4.message.Message
的用法示例。
在下文中一共展示了Message.data_size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testMaxDataSize
# 需要导入模块: from Pyro4.message import Message [as 别名]
# 或者: from Pyro4.message.Message import data_size [as 别名]
def testMaxDataSize(self):
msg = Message(Pyro4.message.MSG_CONNECT, b"hello", 42, 0, 0)
msg.data_size = 0x7fffffff # still within 32 bits signed limits
msg.to_bytes()
msg.data_size = 0x80000000 # overflow, Pyro has a 2 gigabyte message size limitation
with self.assertRaises(ValueError) as ex:
msg.to_bytes()
self.assertEqual("invalid message size (outside range 0..2Gb)", str(ex.exception))
msg.data_size = -42
with self.assertRaises(ValueError) as ex:
msg.to_bytes()
self.assertEqual("invalid message size (outside range 0..2Gb)", str(ex.exception))
示例2: testMessageHeaderDatasize
# 需要导入模块: from Pyro4.message import Message [as 别名]
# 或者: from Pyro4.message.Message import data_size [as 别名]
def testMessageHeaderDatasize(self):
msg = Message(Pyro4.message.MSG_RESULT, b"hello", 12345, 60006, 30003, hmac_key=b"secret")
msg.data_size = 0x12345678 # hack it to a large value to see if it comes back ok
hdr = msg.to_bytes()[:24]
msg = Message.from_header(hdr)
self.assertEqual(Pyro4.message.MSG_RESULT, msg.type)
self.assertEqual(60006, msg.flags)
self.assertEqual(0x12345678, msg.data_size)
self.assertEqual(12345, msg.serializer_id)
self.assertEqual(30003, msg.seq)