summaryrefslogtreecommitdiff
path: root/test/test_limits.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_limits.py')
-rw-r--r--test/test_limits.py46
1 files changed, 27 insertions, 19 deletions
diff --git a/test/test_limits.py b/test/test_limits.py
index 8c7606f..6e85030 100644
--- a/test/test_limits.py
+++ b/test/test_limits.py
@@ -4,8 +4,14 @@ from __future__ import absolute_import, division, print_function, unicode_litera
import pytest
from msgpack import (
- packb, unpackb, Packer, Unpacker, ExtType,
- PackOverflowError, PackValueError, UnpackValueError,
+ packb,
+ unpackb,
+ Packer,
+ Unpacker,
+ ExtType,
+ PackOverflowError,
+ PackValueError,
+ UnpackValueError,
)
@@ -13,30 +19,30 @@ def test_integer():
x = -(2 ** 63)
assert unpackb(packb(x)) == x
with pytest.raises(PackOverflowError):
- packb(x-1)
+ packb(x - 1)
x = 2 ** 64 - 1
assert unpackb(packb(x)) == x
with pytest.raises(PackOverflowError):
- packb(x+1)
+ packb(x + 1)
def test_array_header():
packer = Packer()
- packer.pack_array_header(2**32-1)
+ packer.pack_array_header(2 ** 32 - 1)
with pytest.raises(PackValueError):
- packer.pack_array_header(2**32)
+ packer.pack_array_header(2 ** 32)
def test_map_header():
packer = Packer()
- packer.pack_map_header(2**32-1)
+ packer.pack_map_header(2 ** 32 - 1)
with pytest.raises(PackValueError):
- packer.pack_array_header(2**32)
+ packer.pack_array_header(2 ** 32)
def test_max_str_len():
- d = 'x' * 3
+ d = "x" * 3
packed = packb(d)
unpacker = Unpacker(max_str_len=3, raw=False)
@@ -50,7 +56,7 @@ def test_max_str_len():
def test_max_bin_len():
- d = b'x' * 3
+ d = b"x" * 3
packed = packb(d, use_bin_type=True)
unpacker = Unpacker(max_bin_len=3)
@@ -64,7 +70,7 @@ def test_max_bin_len():
def test_max_array_len():
- d = [1,2,3]
+ d = [1, 2, 3]
packed = packb(d)
unpacker = Unpacker(max_array_len=3)
@@ -107,8 +113,8 @@ def test_max_ext_len():
# PyPy fails following tests because of constant folding?
# https://bugs.pypy.org/issue1721
-#@pytest.mark.skipif(True, reason="Requires very large memory.")
-#def test_binary():
+# @pytest.mark.skipif(True, reason="Requires very large memory.")
+# def test_binary():
# x = b'x' * (2**32 - 1)
# assert unpackb(packb(x)) == x
# del x
@@ -117,8 +123,8 @@ def test_max_ext_len():
# packb(x)
#
#
-#@pytest.mark.skipif(True, reason="Requires very large memory.")
-#def test_string():
+# @pytest.mark.skipif(True, reason="Requires very large memory.")
+# def test_string():
# x = 'x' * (2**32 - 1)
# assert unpackb(packb(x)) == x
# x += 'y'
@@ -126,8 +132,8 @@ def test_max_ext_len():
# packb(x)
#
#
-#@pytest.mark.skipif(True, reason="Requires very large memory.")
-#def test_array():
+# @pytest.mark.skipif(True, reason="Requires very large memory.")
+# def test_array():
# x = [0] * (2**32 - 1)
# assert unpackb(packb(x)) == x
# x.append(0)
@@ -137,8 +143,9 @@ def test_max_ext_len():
# auto max len
+
def test_auto_max_array_len():
- packed = b'\xde\x00\x06zz'
+ packed = b"\xde\x00\x06zz"
with pytest.raises(UnpackValueError):
unpackb(packed, raw=False)
@@ -147,9 +154,10 @@ def test_auto_max_array_len():
with pytest.raises(UnpackValueError):
unpacker.unpack()
+
def test_auto_max_map_len():
# len(packed) == 6 -> max_map_len == 3
- packed = b'\xde\x00\x04zzz'
+ packed = b"\xde\x00\x04zzz"
with pytest.raises(UnpackValueError):
unpackb(packed, raw=False)