mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-11-02 02:20:54 +00:00
Add list_hook option to unpacker.
This commit is contained in:
parent
0076d42a0d
commit
3d8978417a
4 changed files with 43 additions and 13 deletions
|
|
@ -31,7 +31,16 @@ def test_bad_hook():
|
|||
packed = packs([3, 1+2j], default=lambda o: o)
|
||||
unpacked = unpacks(packed)
|
||||
|
||||
def _arr_to_str(arr):
|
||||
return ''.join(str(c) for c in arr)
|
||||
|
||||
def test_array_hook():
|
||||
packed = packs([1,2,3])
|
||||
unpacked = unpacks(packed, list_hook=_arr_to_str)
|
||||
eq_(unpacked, '123')
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_decode_hook()
|
||||
test_encode_hook()
|
||||
test_bad_hook()
|
||||
test_array_hook()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue