summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/test_case.py12
-rw-r--r--test/test_except.py4
-rw-r--r--test/test_format.py4
-rw-r--r--test/test_obj.py18
-rw-r--r--test/test_pack.py20
5 files changed, 29 insertions, 29 deletions
diff --git a/test/test_case.py b/test/test_case.py
index 2f42316..b88714d 100644
--- a/test/test_case.py
+++ b/test/test_case.py
@@ -3,13 +3,13 @@
from nose import main
from nose.tools import *
-from msgpack import packs, unpacks
+from msgpack import packb, unpackb
def check(length, obj):
- v = packs(obj)
+ v = packb(obj)
assert_equal(len(v), length, "%r length should be %r but get %r" % (obj, length, len(v)))
- assert_equal(unpacks(v), obj)
+ assert_equal(unpackb(v), obj)
def test_1():
for o in [None, True, False, 0, 1, (1 << 6), (1 << 7) - 1, -1,
@@ -70,8 +70,8 @@ def test_array32():
def match(obj, buf):
- assert_equal(packs(obj), buf)
- assert_equal(unpacks(buf), obj)
+ assert_equal(packb(obj), buf)
+ assert_equal(unpackb(buf), obj)
def test_match():
cases = [
@@ -99,7 +99,7 @@ def test_match():
match(v, p)
def test_unicode():
- assert_equal(b'foobar', unpacks(packs('foobar')))
+ assert_equal(b'foobar', unpackb(packb('foobar')))
if __name__ == '__main__':
main()
diff --git a/test/test_except.py b/test/test_except.py
index 574728f..ad02cb6 100644
--- a/test/test_except.py
+++ b/test/test_except.py
@@ -2,12 +2,12 @@
# coding: utf-8
from nose.tools import *
-from msgpack import packs, unpacks
+from msgpack import packb, unpackb
import datetime
def test_raise_on_find_unsupported_value():
- assert_raises(TypeError, packs, datetime.datetime.now())
+ assert_raises(TypeError, packb, datetime.datetime.now())
if __name__ == '__main__':
from nose import main
diff --git a/test/test_format.py b/test/test_format.py
index 022e680..c03b3e2 100644
--- a/test/test_format.py
+++ b/test/test_format.py
@@ -3,10 +3,10 @@
from nose import main
from nose.tools import *
-from msgpack import unpacks
+from msgpack import unpackb
def check(src, should):
- assert_equal(unpacks(src), should)
+ assert_equal(unpackb(src), should)
def testSimpleValue():
check(b"\x93\xc0\xc2\xc3",
diff --git a/test/test_obj.py b/test/test_obj.py
index 6357cfc..d155b73 100644
--- a/test/test_obj.py
+++ b/test/test_obj.py
@@ -4,7 +4,7 @@
from nose import main
from nose.tools import *
-from msgpack import packs, unpacks
+from msgpack import packb, unpackb
def _decode_complex(obj):
if b'__complex__' in obj:
@@ -17,26 +17,26 @@ def _encode_complex(obj):
return obj
def test_encode_hook():
- packed = packs([3, 1+2j], default=_encode_complex)
- unpacked = unpacks(packed)
+ packed = packb([3, 1+2j], default=_encode_complex)
+ unpacked = unpackb(packed)
eq_(unpacked[1], {b'__complex__': True, b'real': 1, b'imag': 2})
def test_decode_hook():
- packed = packs([3, {b'__complex__': True, b'real': 1, b'imag': 2}])
- unpacked = unpacks(packed, object_hook=_decode_complex)
+ packed = packb([3, {b'__complex__': True, b'real': 1, b'imag': 2}])
+ unpacked = unpackb(packed, object_hook=_decode_complex)
eq_(unpacked[1], 1+2j)
@raises(ValueError)
def test_bad_hook():
- packed = packs([3, 1+2j], default=lambda o: o)
- unpacked = unpacks(packed)
+ packed = packb([3, 1+2j], default=lambda o: o)
+ unpacked = unpackb(packed)
def _arr_to_str(arr):
return ''.join(str(c) for c in arr)
def test_array_hook():
- packed = packs([1,2,3])
- unpacked = unpacks(packed, list_hook=_arr_to_str)
+ packed = packb([1,2,3])
+ unpacked = unpackb(packed, list_hook=_arr_to_str)
eq_(unpacked, '123')
if __name__ == '__main__':
diff --git a/test/test_pack.py b/test/test_pack.py
index 88b6dac..898cdb9 100644
--- a/test/test_pack.py
+++ b/test/test_pack.py
@@ -6,12 +6,12 @@ from nose import main
from nose.tools import *
from nose.plugins.skip import SkipTest
-from msgpack import packs, unpacks, Unpacker, Packer
+from msgpack import packb, unpackb, Unpacker, Packer
from io import BytesIO
def check(data):
- re = unpacks(packs(data))
+ re = unpackb(packb(data))
assert_equal(re, data)
def testPack():
@@ -33,7 +33,7 @@ def testPackUnicode():
six.u(""), six.u("abcd"), (six.u("defgh"),), six.u("Русский текст"),
]
for td in test_data:
- re = unpacks(packs(td, encoding='utf-8'), encoding='utf-8')
+ re = unpackb(packb(td, encoding='utf-8'), encoding='utf-8')
assert_equal(re, td)
packer = Packer(encoding='utf-8')
data = packer.pack(td)
@@ -49,7 +49,7 @@ def testPackUTF32():
six.u("Русский текст"),
]
for td in test_data:
- re = unpacks(packs(td, encoding='utf-32'), encoding='utf-32')
+ re = unpackb(packb(td, encoding='utf-32'), encoding='utf-32')
assert_equal(re, td)
except LookupError:
raise SkipTest
@@ -62,28 +62,28 @@ def testPackBytes():
check(td)
def testIgnoreUnicodeErrors():
- re = unpacks(packs(b'abc\xeddef'),
+ re = unpackb(packb(b'abc\xeddef'),
encoding='utf-8', unicode_errors='ignore')
assert_equal(re, "abcdef")
@raises(UnicodeDecodeError)
def testStrictUnicodeUnpack():
- unpacks(packs(b'abc\xeddef'), encoding='utf-8')
+ unpackb(packb(b'abc\xeddef'), encoding='utf-8')
@raises(UnicodeEncodeError)
def testStrictUnicodePack():
- packs(six.u("abc\xeddef"), encoding='ascii', unicode_errors='strict')
+ packb(six.u("abc\xeddef"), encoding='ascii', unicode_errors='strict')
def testIgnoreErrorsPack():
- re = unpacks(packs(six.u("abcФФФdef"), encoding='ascii', unicode_errors='ignore'), encoding='utf-8')
+ re = unpackb(packb(six.u("abcФФФdef"), encoding='ascii', unicode_errors='ignore'), encoding='utf-8')
assert_equal(re, six.u("abcdef"))
@raises(TypeError)
def testNoEncoding():
- packs(six.u("abc"), encoding=None)
+ packb(six.u("abc"), encoding=None)
def testDecodeBinary():
- re = unpacks(packs("abc"), encoding=None)
+ re = unpackb(packb("abc"), encoding=None)
assert_equal(re, b"abc")
if __name__ == '__main__':