summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorInada Naoki <songofacandy@gmail.com>2022-05-24 19:46:51 +0900
committerGitHub <noreply@github.com>2022-05-24 19:46:51 +0900
commit500a238028bdebe123b502b07769578b5f0e8a3a (patch)
tree9c5796a126485a13c3963a84e30a4542df9b2fe4 /test
parentb75e3412fb8a2b6d6cd1da1b7063e14f6bfc0337 (diff)
downloadmsgpack-python-500a238028bdebe123b502b07769578b5f0e8a3a.tar.gz
Fix Unpacker max_buffer_length handling (#506)
Diffstat (limited to 'test')
-rw-r--r--test/test_sequnpack.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/test/test_sequnpack.py b/test/test_sequnpack.py
index 9f20c07..c091076 100644
--- a/test/test_sequnpack.py
+++ b/test/test_sequnpack.py
@@ -2,7 +2,7 @@
# coding: utf-8
import io
from msgpack import Unpacker, BufferFull
-from msgpack import pack
+from msgpack import pack, packb
from msgpack.exceptions import OutOfData
from pytest import raises
@@ -78,6 +78,15 @@ def test_maxbuffersize():
assert ord("b") == next(unpacker)
+def test_maxbuffersize_file():
+ buff = io.BytesIO(packb(b"a" * 10) + packb([b"a" * 20] * 2))
+ unpacker = Unpacker(buff, read_size=1, max_buffer_size=19, max_bin_len=20)
+ assert unpacker.unpack() == b"a" * 10
+ # assert unpacker.unpack() == [b"a" * 20]*2
+ with raises(BufferFull):
+ print(unpacker.unpack())
+
+
def test_readbytes():
unpacker = Unpacker(read_size=3)
unpacker.feed(b"foobar")