How to use the msgpack.unpacks function in msgpack

To help you get started, we’ve selected a few msgpack examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github msgpack / msgpack-python / test3 / test_pack.py View on Github external
def testIgnoreErrorsPack():
    re = unpacks(packs("abcФФФdef", encoding='ascii', unicode_errors='ignore'), encoding='utf-8')
    assert_equal(re, "abcdef")
github msgpack / msgpack-ruby / python / test3 / test_obj.py View on Github external
@raises(ValueError)
def test_bad_hook():
    packed = packs([3, 1+2j], default=lambda o: o)
    unpacked = unpacks(packed)
github msgpack / msgpack-python / test3 / test_case.py View on Github external
def check(length, obj):
    v = packs(obj)
    assert_equal(len(v), length, "%r length should be %r but get %r" % (obj, length, len(v)))
    assert_equal(unpacks(v), obj)
github msgpack / msgpack-python / test3 / test_pack.py View on Github external
def check(data):
    re = unpacks(packs(data))
    assert_equal(re, data)
github msgpack / msgpack-python / test3 / test_obj.py View on Github external
def test_decode_hook():
    packed = packs([3, {b'__complex__': True, b'real': 1, b'imag': 2}])
    unpacked = unpacks(packed, object_hook=_decode_complex)
    eq_(unpacked[1], 1+2j)
github keisukefukuda / msgpack-python-pure / tests / test_main.py View on Github external
def _check_decode(bytes):
    packed = struct.pack("B" * len(bytes), *bytes)
    assert msgpack.unpacks(packed) == msgpack_pure.unpacks(packed)
github msgpack / msgpack-python / test3 / test_obj.py View on Github external
def test_encode_hook():
    packed = packs([3, 1+2j], default=_encode_complex)
    unpacked = unpacks(packed)
    eq_(unpacked[1], {b'__complex__': True, b'real': 1, b'imag': 2})
github keisukefukuda / msgpack-python-pure / tests / test_pack.py View on Github external
def check(data):
    re = unpacks(packs(data))
    assert_equal(re, data)
github keisukefukuda / msgpack-python-pure / tests / test_main.py View on Github external
def _check(obj):
    # NOTE:
    # msgpack.packs(obj) nad msgpack_pure.packs(obj) are not necessarily
    # match because there are some possible variations which type to use
    # for integer values (i.e. uint8/int16 for 0xFF).
    obj = _list_to_tuple(obj)
    
    assert msgpack_pure.unpacks(msgpack.packs(obj)) == obj
    assert msgpack.unpacks(msgpack_pure.packs(obj)) == obj
    assert msgpack_pure.unpacks(msgpack_pure.packs(obj)) == obj
github msgpack / msgpack-python / test3 / test_case.py View on Github external
def test_unicode():
    assert_equal(b'foobar', unpacks(packs('foobar')))