本文整理匯總了Python中msgpack.Packer.pack_array_header方法的典型用法代碼示例。如果您正苦於以下問題:Python Packer.pack_array_header方法的具體用法?Python Packer.pack_array_header怎麽用?Python Packer.pack_array_header使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類msgpack.Packer
的用法示例。
在下文中一共展示了Packer.pack_array_header方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_manualreset
# 需要導入模塊: from msgpack import Packer [as 別名]
# 或者: from msgpack.Packer import pack_array_header [as 別名]
def test_manualreset(sizes=[0, 5, 50, 1000]):
packer = Packer(autoreset=False)
for size in sizes:
packer.pack_array_header(size)
for i in range(size):
packer.pack(i)
bio = BytesIO(packer.bytes())
unpacker = Unpacker(bio, use_list=1)
for size in sizes:
assert unpacker.unpack() == list(range(size))
packer.reset()
assert packer.bytes() == b''
示例2: testArraySize
# 需要導入模塊: from msgpack import Packer [as 別名]
# 或者: from msgpack.Packer import pack_array_header [as 別名]
def testArraySize(sizes=[0, 5, 50, 1000]):
bio = BytesIO()
packer = Packer()
for size in sizes:
bio.write(packer.pack_array_header(size))
for i in range(size):
bio.write(packer.pack(i))
bio.seek(0)
unpacker = Unpacker(bio, use_list=1)
for size in sizes:
assert unpacker.unpack() == list(range(size))
示例3: test_map_header
# 需要導入模塊: from msgpack import Packer [as 別名]
# 或者: from msgpack.Packer import pack_array_header [as 別名]
def test_map_header():
packer = Packer()
packer.pack_map_header(2**32-1)
with pytest.raises((OverflowError, ValueError)):
packer.pack_array_header(2**32)
示例4: test_map_header
# 需要導入模塊: from msgpack import Packer [as 別名]
# 或者: from msgpack.Packer import pack_array_header [as 別名]
def test_map_header():
packer = Packer()
packer.pack_map_header(2**32-1)
with pytest.raises(PackValueError):
packer.pack_array_header(2**32)