summaryrefslogtreecommitdiff
path: root/test/test_pack.py
diff options
context:
space:
mode:
authorINADA Naoki <inada-n@klab.com>2012-12-10 21:47:18 +0900
committerINADA Naoki <inada-n@klab.com>2012-12-10 21:47:18 +0900
commit4adc6f194d9986eee4cfa4999d30862e4251d4cf (patch)
tree24a6334399e7cd1f6e1cb9b318d5f273bb26ef04 /test/test_pack.py
parent537a2ab3f262d65f5a85741ddbb4ac6604ed7e0b (diff)
downloadmsgpack-python-4adc6f194d9986eee4cfa4999d30862e4251d4cf.tar.gz
Add `autoreset` option to Packer.
Diffstat (limited to 'test/test_pack.py')
-rw-r--r--test/test_pack.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/test_pack.py b/test/test_pack.py
index b918f8e..b934dd2 100644
--- a/test/test_pack.py
+++ b/test/test_pack.py
@@ -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()