本文整理汇总了Python中msgpack.Unpacker.read_array_header方法的典型用法代码示例。如果您正苦于以下问题:Python Unpacker.read_array_header方法的具体用法?Python Unpacker.read_array_header怎么用?Python Unpacker.read_array_header使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msgpack.Unpacker
的用法示例。
在下文中一共展示了Unpacker.read_array_header方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_correct_type_nested_array
# 需要导入模块: from msgpack import Unpacker [as 别名]
# 或者: from msgpack.Unpacker import read_array_header [as 别名]
def test_correct_type_nested_array():
unpacker = Unpacker()
unpacker.feed(packb({'a': ['b', 'c', 'd']}))
try:
unpacker.read_array_header()
assert 0, 'should raise exception'
except UnexpectedTypeException:
assert 1, 'okay'
示例2: test_incorrect_type_array
# 需要导入模块: from msgpack import Unpacker [as 别名]
# 或者: from msgpack.Unpacker import read_array_header [as 别名]
def test_incorrect_type_array():
unpacker = Unpacker()
unpacker.feed(packb(1))
try:
unpacker.read_array_header()
assert 0, 'should raise exception'
except UnexpectedTypeException:
assert 1, 'okay'
示例3: test_unpack_array_header_from_file
# 需要导入模块: from msgpack import Unpacker [as 别名]
# 或者: from msgpack.Unpacker import read_array_header [as 别名]
def test_unpack_array_header_from_file():
f = BytesIO(packb([1,2,3,4]))
unpacker = Unpacker(f)
assert unpacker.read_array_header() == 4
assert unpacker.unpack() == 1
assert unpacker.unpack() == 2
assert unpacker.unpack() == 3
assert unpacker.unpack() == 4
with raises(OutOfData):
unpacker.unpack()
示例4: test_read_array_header
# 需要导入模块: from msgpack import Unpacker [as 别名]
# 或者: from msgpack.Unpacker import read_array_header [as 别名]
def test_read_array_header():
unpacker = Unpacker()
unpacker.feed(packb(['a', 'b', 'c']))
assert unpacker.read_array_header() == 3
assert unpacker.unpack() == b'a'
assert unpacker.unpack() == b'b'
assert unpacker.unpack() == b'c'
try:
unpacker.unpack()
assert 0, 'should raise exception'
except OutOfData:
assert 1, 'okay'
示例5: test_read_array_header
# 需要导入模块: from msgpack import Unpacker [as 别名]
# 或者: from msgpack.Unpacker import read_array_header [as 别名]
def test_read_array_header():
unpacker = Unpacker()
unpacker.feed(packb(["a", "b", "c"]))
assert unpacker.read_array_header() == 3
assert unpacker.unpack() == b"a"
assert unpacker.unpack() == b"b"
assert unpacker.unpack() == b"c"
try:
unpacker.unpack()
assert 0, "should raise exception"
except StopIteration:
assert 1, "okay"