Skip to content

Commit dc2cefe

Browse files
test: add test
1 parent e24d5de commit dc2cefe

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

test/test_except.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,17 @@ def test_strict_map_key():
8989
packed = packb(invalid, use_bin_type=True)
9090
with raises(ValueError):
9191
unpackb(packed, raw=False, strict_map_key=True)
92+
93+
94+
def test_strict_map_key_with_object_pairs_hook():
95+
# strict_map_key should be enforced even when object_pairs_hook is set
96+
invalid = {42: "value"}
97+
packed = packb(invalid, use_bin_type=True)
98+
with raises(ValueError):
99+
unpackb(packed, raw=False, strict_map_key=True, object_pairs_hook=list)
100+
101+
# valid keys (str/bytes) should still work with object_pairs_hook
102+
valid = {"key": "value"}
103+
packed = packb(valid, use_bin_type=True)
104+
result = unpackb(packed, raw=False, strict_map_key=True, object_pairs_hook=list)
105+
assert result == [("key", "value")]

0 commit comments

Comments
 (0)