summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorINADA Naoki <methane@users.noreply.github.com>2018-11-30 11:47:15 +0900
committerGitHub <noreply@github.com>2018-11-30 11:47:15 +0900
commit760e30b77e4ec26dbfebb9c5adbd43933fca18bc (patch)
tree69294aedf5c7b313593fc3f9f566659957312f25 /test
parent3c9c6edbc88908fceb3c69ff3d6455be8b5914c8 (diff)
parent8ae6320072e746fad29bc14a095569811e009695 (diff)
downloadmsgpack-python-760e30b77e4ec26dbfebb9c5adbd43933fca18bc.tar.gz
unpacker: Add `strict_map_key` option (#334)
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..5544f2b 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=False, strict_map_key=True)
+
+ invalid = {42: 1}
+ packed = packb(invalid, use_bin_type=True)
+ with raises(ValueError):
+ unpackb(packed, raw=False, strict_map_key=True)