We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b7806a6 commit 2d05b40Copy full SHA for 2d05b40
test/test_extension.py
@@ -55,3 +55,22 @@ def ext_hook(code, data):
55
s = msgpack.packb(obj, default=default)
56
obj2 = msgpack.unpackb(s, ext_hook=ext_hook)
57
assert obj == obj2
58
+
59
+import sys
60
+if sys.version > '3':
61
+ long = int
62
63
+def test_overriding_hooks():
64
+ def default(obj):
65
+ if isinstance(obj, long):
66
+ return {"__type__": "long", "__data__": str(obj)}
67
+ else:
68
+ return obj
69
70
+ obj = {"testval": long(1823746192837461928374619)}
71
+ refobj = {"testval": default(obj["testval"])}
72
+ refout = msgpack.packb(refobj)
73
+ assert isinstance(refout, (str, bytes))
74
+ testout = msgpack.packb(obj, default=default)
75
76
+ assert refout == testout
0 commit comments