mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-06 17:59:52 +00:00
parent
d9ec8fc905
commit
5569a4efcd
9 changed files with 48 additions and 47 deletions
|
|
@ -39,11 +39,11 @@ def test_max_str_len():
|
|||
d = 'x' * 3
|
||||
packed = packb(d)
|
||||
|
||||
unpacker = Unpacker(max_str_len=3, raw_as_bytes=False)
|
||||
unpacker = Unpacker(max_str_len=3, raw=False)
|
||||
unpacker.feed(packed)
|
||||
assert unpacker.unpack() == d
|
||||
|
||||
unpacker = Unpacker(max_str_len=2, raw_as_bytes=False)
|
||||
unpacker = Unpacker(max_str_len=2, raw=False)
|
||||
with pytest.raises(UnpackValueError):
|
||||
unpacker.feed(packed)
|
||||
unpacker.unpack()
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ def testPack():
|
|||
def testPackUnicode():
|
||||
test_data = ["", "abcd", ["defgh"], "Русский текст"]
|
||||
for td in test_data:
|
||||
re = unpackb(packb(td), use_list=1, raw_as_bytes=False)
|
||||
re = unpackb(packb(td), use_list=1, raw=False)
|
||||
assert re == td
|
||||
packer = Packer()
|
||||
data = packer.pack(td)
|
||||
re = Unpacker(BytesIO(data), raw_as_bytes=False, use_list=1).unpack()
|
||||
re = Unpacker(BytesIO(data), raw=False, use_list=1).unpack()
|
||||
assert re == td
|
||||
|
||||
def testPackUTF32(): # deprecated
|
||||
|
|
@ -72,14 +72,14 @@ def testIgnoreUnicodeErrors(): # deprecated
|
|||
|
||||
def testStrictUnicodeUnpack():
|
||||
with raises(UnicodeDecodeError):
|
||||
unpackb(packb(b'abc\xeddef'), raw_as_bytes=False, use_list=1)
|
||||
unpackb(packb(b'abc\xeddef'), raw=False, use_list=1)
|
||||
|
||||
def testStrictUnicodePack(): # deprecated
|
||||
with raises(UnicodeEncodeError):
|
||||
packb("abc\xeddef", encoding='ascii', unicode_errors='strict')
|
||||
|
||||
def testIgnoreErrorsPack(): # deprecated
|
||||
re = unpackb(packb("abcФФФdef", encoding='ascii', unicode_errors='ignore'), raw_as_bytes=False, use_list=1)
|
||||
re = unpackb(packb("abcФФФdef", encoding='ascii', unicode_errors='ignore'), raw=False, use_list=1)
|
||||
assert re == "abcdef"
|
||||
|
||||
def testDecodeBinary():
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ def test_namedtuple():
|
|||
return dict(o._asdict())
|
||||
raise TypeError('Unsupported type %s' % (type(o),))
|
||||
packed = packb(T(1, 42), strict_types=True, use_bin_type=True, default=default)
|
||||
unpacked = unpackb(packed, raw_as_bytes=False)
|
||||
unpacked = unpackb(packed, raw=False)
|
||||
assert unpacked == {'foo': 1, 'bar': 42}
|
||||
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ def test_tuple():
|
|||
return o
|
||||
|
||||
data = packb(t, strict_types=True, use_bin_type=True, default=default)
|
||||
expected = unpackb(data, raw_as_bytes=False, object_hook=convert)
|
||||
expected = unpackb(data, raw=False, object_hook=convert)
|
||||
|
||||
assert expected == t
|
||||
|
||||
|
|
@ -53,10 +53,10 @@ def test_tuple_ext():
|
|||
def convert(code, payload):
|
||||
if code == MSGPACK_EXT_TYPE_TUPLE:
|
||||
# Unpack and convert to tuple
|
||||
return tuple(unpackb(payload, raw_as_bytes=False, ext_hook=convert))
|
||||
return tuple(unpackb(payload, raw=False, ext_hook=convert))
|
||||
raise ValueError('Unknown Ext code {}'.format(code))
|
||||
|
||||
data = packb(t, strict_types=True, use_bin_type=True, default=default)
|
||||
expected = unpackb(data, raw_as_bytes=False, ext_hook=convert)
|
||||
expected = unpackb(data, raw=False, ext_hook=convert)
|
||||
|
||||
assert expected == t
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ def test_unpacker_ext_hook():
|
|||
|
||||
def __init__(self):
|
||||
super(MyUnpacker, self).__init__(
|
||||
ext_hook=self._hook, raw_as_bytes=False)
|
||||
ext_hook=self._hook, raw=False)
|
||||
|
||||
def _hook(self, code, data):
|
||||
if code == 1:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue