mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-06-19 06:02:09 +00:00
test: add test
This commit is contained in:
parent
e24d5de5ef
commit
dc2cefeaca
1 changed files with 14 additions and 0 deletions
|
|
@ -89,3 +89,17 @@ def test_strict_map_key():
|
|||
packed = packb(invalid, use_bin_type=True)
|
||||
with raises(ValueError):
|
||||
unpackb(packed, raw=False, strict_map_key=True)
|
||||
|
||||
|
||||
def test_strict_map_key_with_object_pairs_hook():
|
||||
# strict_map_key should be enforced even when object_pairs_hook is set
|
||||
invalid = {42: "value"}
|
||||
packed = packb(invalid, use_bin_type=True)
|
||||
with raises(ValueError):
|
||||
unpackb(packed, raw=False, strict_map_key=True, object_pairs_hook=list)
|
||||
|
||||
# valid keys (str/bytes) should still work with object_pairs_hook
|
||||
valid = {"key": "value"}
|
||||
packed = packb(valid, use_bin_type=True)
|
||||
result = unpackb(packed, raw=False, strict_map_key=True, object_pairs_hook=list)
|
||||
assert result == [("key", "value")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue