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
def test_array_hook():
    packed = packs([1,2,3])
    unpacked = unpacks(packed, list_hook=_arr_to_str)
    eq_(unpacked, '123')
def test_bad_hook():
    packed = packs([3, 1+2j], default=lambda o: o)
    unpacked = unpacks(packed)
def test_decode_hook():
    packed = packs([3, {'__complex__': True, 'real': 1, 'imag': 2}])
    unpacked = unpacks(packed, object_hook=_decode_complex)
    eq_(unpacked[1], 1+2j)
def test_encode_hook():
    packed = packs([3, 1+2j], default=_encode_complex)
    unpacked = unpacks(packed)
    eq_(unpacked[1], {'__complex__': True, 'real': 1, 'imag': 2})
def match(obj, buf):
    assert_equal(packs(obj), buf)
    assert_equal(unpacks(buf), obj)
def test_unicode():
    assert_equal('foobar', unpacks(packs(u'foobar')))
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)