summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorInada Naoki <methane@users.noreply.github.com>2019-01-24 18:46:39 +0900
committerGitHub <noreply@github.com>2019-01-24 18:46:39 +0900
commit28b5f46a34933cc177aca333203d1344b5e3639a (patch)
tree72202599bf4a6610675cf134757124eea6261c93 /test
parentf46523b1af7ff2d408da8500ea36a4f9f2abe915 (diff)
downloadmsgpack-python-28b5f46a34933cc177aca333203d1344b5e3639a.tar.gz
Auto limit configuration (#342)
Diffstat (limited to 'test')
-rw-r--r--test/test_limits.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/test/test_limits.py b/test/test_limits.py
index 74e48c1..8c7606f 100644
--- a/test/test_limits.py
+++ b/test/test_limits.py
@@ -105,7 +105,6 @@ def test_max_ext_len():
unpacker.unpack()
-
# PyPy fails following tests because of constant folding?
# https://bugs.pypy.org/issue1721
#@pytest.mark.skipif(True, reason="Requires very large memory.")
@@ -134,3 +133,27 @@ def test_max_ext_len():
# x.append(0)
# with pytest.raises(ValueError):
# packb(x)
+
+
+# auto max len
+
+def test_auto_max_array_len():
+ packed = b'\xde\x00\x06zz'
+ with pytest.raises(UnpackValueError):
+ unpackb(packed, raw=False)
+
+ unpacker = Unpacker(max_buffer_size=5, raw=False)
+ unpacker.feed(packed)
+ with pytest.raises(UnpackValueError):
+ unpacker.unpack()
+
+def test_auto_max_map_len():
+ # len(packed) == 6 -> max_map_len == 3
+ packed = b'\xde\x00\x04zzz'
+ with pytest.raises(UnpackValueError):
+ unpackb(packed, raw=False)
+
+ unpacker = Unpacker(max_buffer_size=6, raw=False)
+ unpacker.feed(packed)
+ with pytest.raises(UnpackValueError):
+ unpacker.unpack()