How to use the msgpack.packs 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 testDecodeBinary():
    re = unpacks(packs("abc"), encoding=None)
    assert_equal(re, b"abc")
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_pack.py View on Github external
def testPackUTF32():
    test_data = [
        "", "abcd", ("defgh",), "Русский текст",
        ]
    for td in test_data:
        re = unpacks(packs(td, encoding='utf-32'), encoding='utf-32')
        assert_equal(re, td)
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 msgpack / msgpack-python / test3 / test_obj.py View on Github external
def test_array_hook():
    packed = packs([1,2,3])
    unpacked = unpacks(packed, list_hook=_arr_to_str)
    eq_(unpacked, '123')
github msgpack / msgpack-python / test3 / test_case.py View on Github external
def match(obj, buf):
    assert_equal(packs(obj), buf)
    assert_equal(unpacks(buf), obj)
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 mozilla / mozillians / vendor-local / lib / python / kombu / serialization.py View on Github external
def register_msgpack():
    """See http://msgpack.sourceforge.net/"""
    try:
        import msgpack
        registry.register('msgpack', msgpack.packs, msgpack.unpacks,
                content_type='application/x-msgpack',
                content_encoding='binary')
    except ImportError:

        def not_available(*args, **kwargs):
            """In case a client receives a msgpack message, but yaml
            isn't installed."""
            raise SerializerNotInstalled(
                    "No decoder installed for msgpack. "
                    "Install the msgpack library")
        registry.register('msgpack', None, not_available,
                          'application/x-msgpack')