summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorInada Naoki <songofacandy@gmail.com>2019-12-06 22:23:15 +0900
committerGitHub <noreply@github.com>2019-12-06 22:23:15 +0900
commitd8e3cf0563989a660398318a7c788645124e1d8b (patch)
treebd4db6fa691dd01930e751570bbddb559db1302a /test
parent0fc0eb2f16fcc7d0271792f93a90af389f66dafb (diff)
downloadmsgpack-python-d8e3cf0563989a660398318a7c788645124e1d8b.tar.gz
Make strict_map_key default to True (#392)
Diffstat (limited to 'test')
-rw-r--r--test/test_case.py2
-rw-r--r--test/test_format.py2
-rw-r--r--test/test_limits.py4
-rw-r--r--test/test_obj.py9
-rw-r--r--test/test_pack.py6
-rw-r--r--test/test_sequnpack.py2
6 files changed, 14 insertions, 11 deletions
diff --git a/test/test_case.py b/test/test_case.py
index 3e60e59..a0a3c5a 100644
--- a/test/test_case.py
+++ b/test/test_case.py
@@ -92,7 +92,7 @@ def test_array32():
def match(obj, buf):
assert packb(obj) == buf
- assert unpackb(buf, use_list=0) == obj
+ assert unpackb(buf, use_list=0, strict_map_key=False) == obj
def test_match():
diff --git a/test/test_format.py b/test/test_format.py
index 8c2f03f..d455f7c 100644
--- a/test/test_format.py
+++ b/test/test_format.py
@@ -5,7 +5,7 @@ from msgpack import unpackb
def check(src, should, use_list=0, raw=True):
- assert unpackb(src, use_list=use_list, raw=raw) == should
+ assert unpackb(src, use_list=use_list, raw=raw, strict_map_key=False) == should
def testSimpleValue():
diff --git a/test/test_limits.py b/test/test_limits.py
index 6e85030..65e6bcc 100644
--- a/test/test_limits.py
+++ b/test/test_limits.py
@@ -87,11 +87,11 @@ def test_max_map_len():
d = {1: 2, 3: 4, 5: 6}
packed = packb(d)
- unpacker = Unpacker(max_map_len=3)
+ unpacker = Unpacker(max_map_len=3, strict_map_key=False)
unpacker.feed(packed)
assert unpacker.unpack() == d
- unpacker = Unpacker(max_map_len=2)
+ unpacker = Unpacker(max_map_len=2, strict_map_key=False)
with pytest.raises(UnpackValueError):
unpacker.feed(packed)
unpacker.unpack()
diff --git a/test/test_obj.py b/test/test_obj.py
index 0b99cea..86c557c 100644
--- a/test/test_obj.py
+++ b/test/test_obj.py
@@ -33,7 +33,10 @@ def test_decode_pairs_hook():
packed = packb([3, {1: 2, 3: 4}])
prod_sum = 1 * 2 + 3 * 4
unpacked = unpackb(
- packed, object_pairs_hook=lambda l: sum(k * v for k, v in l), use_list=1
+ packed,
+ object_pairs_hook=lambda l: sum(k * v for k, v in l),
+ use_list=1,
+ strict_map_key=False,
)
assert unpacked[1] == prod_sum
@@ -70,10 +73,10 @@ def bad_complex_decoder(o):
def test_an_exception_in_objecthook1():
with raises(DecodeError):
packed = packb({1: {"__complex__": True, "real": 1, "imag": 2}})
- unpackb(packed, object_hook=bad_complex_decoder)
+ unpackb(packed, object_hook=bad_complex_decoder, strict_map_key=False)
def test_an_exception_in_objecthook2():
with raises(DecodeError):
packed = packb({1: [{"__complex__": True, "real": 1, "imag": 2}]})
- unpackb(packed, list_hook=bad_complex_decoder, use_list=1)
+ unpackb(packed, list_hook=bad_complex_decoder, use_list=1, strict_map_key=False)
diff --git a/test/test_pack.py b/test/test_pack.py
index de212ef..932f760 100644
--- a/test/test_pack.py
+++ b/test/test_pack.py
@@ -14,7 +14,7 @@ from msgpack import packb, unpackb, Unpacker, Packer, pack
def check(data, use_list=False):
- re = unpackb(packb(data), use_list=use_list)
+ re = unpackb(packb(data), use_list=use_list, strict_map_key=False)
assert re == data
@@ -166,7 +166,7 @@ def testMapSize(sizes=[0, 5, 50, 1000]):
bio.write(packer.pack(i * 2)) # value
bio.seek(0)
- unpacker = Unpacker(bio)
+ unpacker = Unpacker(bio, strict_map_key=False)
for size in sizes:
assert unpacker.unpack() == dict((i, i * 2) for i in range(size))
@@ -186,7 +186,7 @@ def test_pairlist():
pairlist = [(b"a", 1), (2, b"b"), (b"foo", b"bar")]
packer = Packer()
packed = packer.pack_map_pairs(pairlist)
- unpacked = unpackb(packed, object_pairs_hook=list)
+ unpacked = unpackb(packed, object_pairs_hook=list, strict_map_key=False)
assert pairlist == unpacked
diff --git a/test/test_sequnpack.py b/test/test_sequnpack.py
index ad29de8..6293a45 100644
--- a/test/test_sequnpack.py
+++ b/test/test_sequnpack.py
@@ -132,7 +132,7 @@ def test_unpack_tell():
pack(m, stream)
offsets.append(stream.tell())
stream.seek(0)
- unpacker = Unpacker(stream)
+ unpacker = Unpacker(stream, strict_map_key=False)
for m, o in zip(messages, offsets):
m2 = next(unpacker)
assert m == m2