summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorInada Naoki <songofacandy@gmail.com>2018-11-29 22:29:38 +0900
committerInada Naoki <songofacandy@gmail.com>2018-11-29 22:29:38 +0900
commite9086a34e4b3d64df78314339f152c800e79c8e1 (patch)
treed4b46ab4c67c7195d3370829b57e1ac692f2cedb /test
parent3c9c6edbc88908fceb3c69ff3d6455be8b5914c8 (diff)
downloadmsgpack-python-e9086a34e4b3d64df78314339f152c800e79c8e1.tar.gz
Add strict_map_key option to unpacker
Diffstat (limited to 'test')
-rw-r--r--test/test_except.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/test_except.py b/test/test_except.py
index 626c8be..40ca3ee 100644
--- a/test/test_except.py
+++ b/test/test_except.py
@@ -50,3 +50,14 @@ def test_invalidvalue():
with raises(StackError):
unpackb(b"\x91" * 3000) # nested fixarray(len=1)
+
+
+def test_strict_map_key():
+ valid = {u"unicode": 1, b"bytes": 2}
+ packed = packb(valid, use_bin_type=True)
+ assert valid == unpackb(packed, raw=True)
+
+ invalid = {42: 1}
+ packed = packb(invalid, use_bin_type=True)
+ with raises(ValueError):
+ unpackb(packed, raw=True)