summaryrefslogtreecommitdiff
path: root/test/test_extension.py
diff options
context:
space:
mode:
authorINADA Naoki <inada-n@klab.com>2013-10-20 15:40:20 +0900
committerINADA Naoki <inada-n@klab.com>2013-10-20 15:40:20 +0900
commitaa68c9b8330b130d600b22ec47d5c3841499b536 (patch)
tree85fd0c30d69180b2afa1602b40bb4775ddf12459 /test/test_extension.py
parent27f0cba8a5f36393517ee85d2c339847b76e0c6b (diff)
downloadmsgpack-python-aa68c9b8330b130d600b22ec47d5c3841499b536.tar.gz
fallback: Support pack_ext_type.
Diffstat (limited to 'test/test_extension.py')
-rw-r--r--test/test_extension.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/test/test_extension.py b/test/test_extension.py
index 94117e1..f2fa363 100644
--- a/test/test_extension.py
+++ b/test/test_extension.py
@@ -1,21 +1,21 @@
-import py
import array
-import struct
import msgpack
-def test_pack_extended_type():
+
+def test_pack_ext_type():
def p(s):
packer = msgpack.Packer()
- packer.pack_extended_type(0x42, s)
+ packer.pack_ext_type(0x42, s)
return packer.bytes()
- assert p('A') == '\xd4\x42A' # fixext 1
- assert p('AB') == '\xd5\x42AB' # fixext 2
- assert p('ABCD') == '\xd6\x42ABCD' # fixext 4
- assert p('ABCDEFGH') == '\xd7\x42ABCDEFGH' # fixext 8
- assert p('A'*16) == '\xd8\x42' + 'A'*16 # fixext 16
- assert p('ABC') == '\xc7\x03\x42ABC' # ext 8
- assert p('A'*0x0123) == '\xc8\x01\x23\x42' + 'A'*0x0123 # ext 16
- assert p('A'*0x00012345) == '\xc9\x00\x01\x23\x45\x42' + 'A'*0x00012345 # ext 32
+ assert p(b'A') == b'\xd4\x42A' # fixext 1
+ assert p(b'AB') == b'\xd5\x42AB' # fixext 2
+ assert p(b'ABCD') == b'\xd6\x42ABCD' # fixext 4
+ assert p(b'ABCDEFGH') == b'\xd7\x42ABCDEFGH' # fixext 8
+ assert p(b'A'*16) == b'\xd8\x42' + 'A'*16 # fixext 16
+ assert p(b'ABC') == b'\xc7\x03\x42ABC' # ext 8
+ assert p(b'A'*0x0123) == b'\xc8\x01\x23\x42' + b'A'*0x0123 # ext 16
+ assert p(b'A'*0x00012345) == b'\xc9\x00\x01\x23\x45\x42' + b'A'*0x00012345 # ext 32
+
def test_unpack_extended_type():
class MyUnpacker(msgpack.Unpacker):
@@ -45,7 +45,7 @@ def test_extension_type():
if isinstance(obj, array.array):
typecode = 123 # application specific typecode
data = obj.tostring()
- self.pack_extended_type(typecode, data)
+ self.pack_ext_type(typecode, data)
return True
class MyUnpacker(msgpack.Unpacker):