summaryrefslogtreecommitdiff
path: root/test/test_sequnpack.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_sequnpack.py')
-rw-r--r--test/test_sequnpack.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/test/test_sequnpack.py b/test/test_sequnpack.py
index 774fe1b..b1b80b2 100644
--- a/test/test_sequnpack.py
+++ b/test/test_sequnpack.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python
# coding: utf-8
-from msgpack import Unpacker
+from msgpack import Unpacker, BufferFull
+import nose
def test_foobar():
unpacker = Unpacker(read_size=3)
@@ -27,6 +28,19 @@ def test_foobar():
k += 1
assert k == len(b'foobar')
-if __name__ == '__main__':
- test_foobar()
+def test_maxbuffersize():
+ nose.tools.assert_raises(ValueError, Unpacker, read_size=5, max_buffer_size=3)
+ unpacker = Unpacker(read_size=3, max_buffer_size=3)
+ unpacker.feed(b'fo')
+ nose.tools.assert_raises(BufferFull, unpacker.feed, b'ob')
+ unpacker.feed(b'o')
+ assert ord('f') == next(unpacker)
+ unpacker.feed(b'b')
+ assert ord('o') == next(unpacker)
+ assert ord('o') == next(unpacker)
+ assert ord('b') == next(unpacker)
+
+
+if __name__ == '__main__':
+ nose.main()