mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-12 12:50:18 +00:00
Add autoreset option to Packer.
This commit is contained in:
parent
537a2ab3f2
commit
4adc6f194d
2 changed files with 51 additions and 12 deletions
|
|
@ -103,6 +103,21 @@ def testArraySize(sizes=[0, 5, 50, 1000]):
|
|||
for size in sizes:
|
||||
assert unpacker.unpack() == list(range(size))
|
||||
|
||||
def test_manualreset(sizes=[0, 5, 50, 1000]):
|
||||
packer = Packer(autoreset=False)
|
||||
for size in sizes:
|
||||
packer.pack_array_header(size)
|
||||
for i in range(size):
|
||||
packer.pack(i)
|
||||
|
||||
bio = six.BytesIO(packer.bytes())
|
||||
unpacker = Unpacker(bio, use_list=1)
|
||||
for size in sizes:
|
||||
assert unpacker.unpack() == list(range(size))
|
||||
|
||||
packer.reset()
|
||||
assert packer.bytes() == b''
|
||||
|
||||
def testMapSize(sizes=[0, 5, 50, 1000]):
|
||||
bio = six.BytesIO()
|
||||
packer = Packer()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue