diff options
author | INADA Naoki <songofacandy@gmail.com> | 2012-07-20 02:02:37 +0900 |
---|---|---|
committer | INADA Naoki <songofacandy@gmail.com> | 2012-07-20 02:02:37 +0900 |
commit | e5462ff72f16517e5e9eb434efad084d874e3967 (patch) | |
tree | 9b9bc948ff122f1d01bec48a330a81db3576d425 | |
parent | 7b1167044b17572126fc69b89eb6fa9c0a5afb91 (diff) | |
download | msgpack-python-e5462ff72f16517e5e9eb434efad084d874e3967.tar.gz |
Add test for max_buffer_size.
-rw-r--r-- | test/test_sequnpack.py | 20 |
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() |