mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-10-19 20:03:16 +00:00
Add Packer.pack_pairs
.
This commit is contained in:
parent
0c7ab7c344
commit
537a2ab3f2
2 changed files with 44 additions and 6 deletions
|
@ -118,8 +118,6 @@ def testMapSize(sizes=[0, 5, 50, 1000]):
|
|||
assert unpacker.unpack() == dict((i, i * 2) for i in range(size))
|
||||
|
||||
|
||||
|
||||
|
||||
class odict(dict):
|
||||
'''Reimplement OrderedDict to run test on Python 2.6'''
|
||||
def __init__(self, seq):
|
||||
|
@ -144,5 +142,14 @@ def test_odict():
|
|||
assert_equal(unpackb(packb(od), object_pairs_hook=pair_hook, use_list=1), seq)
|
||||
|
||||
|
||||
def test_pairlist():
|
||||
pairlist = [(b'a', 1), (2, b'b'), (b'foo', b'bar')]
|
||||
packer = Packer()
|
||||
packed = packer.pack_map_pairs(pairlist)
|
||||
unpacked = unpackb(packed, object_pairs_hook=list)
|
||||
assert pairlist == unpacked
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue