summaryrefslogtreecommitdiff
path: root/test/test_pack.py
diff options
context:
space:
mode:
authorINADA Naoki <methane@users.noreply.github.com>2018-01-11 17:02:41 +0900
committerGitHub <noreply@github.com>2018-01-11 17:02:41 +0900
commit5534d0c7af0114db3d27f7b96c82a7fe22ce1e40 (patch)
tree57d598860b021b723074504bd84391852b376eb9 /test/test_pack.py
parent50ea49c86f5aaff8bb1cd37778b50b13df83ba8f (diff)
downloadmsgpack-python-5534d0c7af0114db3d27f7b96c82a7fe22ce1e40.tar.gz
Add raw_as_bytes option to Unpacker. (#265)
Diffstat (limited to 'test/test_pack.py')
-rw-r--r--test/test_pack.py22
1 files changed, 9 insertions, 13 deletions
diff --git a/test/test_pack.py b/test/test_pack.py
index ac93103..29f5887 100644
--- a/test/test_pack.py
+++ b/test/test_pack.py
@@ -31,14 +31,14 @@ def testPack():
def testPackUnicode():
test_data = ["", "abcd", ["defgh"], "Русский текст"]
for td in test_data:
- re = unpackb(packb(td, encoding='utf-8'), use_list=1, encoding='utf-8')
+ re = unpackb(packb(td), use_list=1, raw_as_bytes=False)
assert re == td
- packer = Packer(encoding='utf-8')
+ packer = Packer()
data = packer.pack(td)
- re = Unpacker(BytesIO(data), encoding=str('utf-8'), use_list=1).unpack()
+ re = Unpacker(BytesIO(data), raw_as_bytes=False, use_list=1).unpack()
assert re == td
-def testPackUTF32():
+def testPackUTF32(): # deprecated
try:
test_data = [
"",
@@ -66,26 +66,22 @@ def testPackByteArrays():
for td in test_data:
check(td)
-def testIgnoreUnicodeErrors():
+def testIgnoreUnicodeErrors(): # deprecated
re = unpackb(packb(b'abc\xeddef'), encoding='utf-8', unicode_errors='ignore', use_list=1)
assert re == "abcdef"
def testStrictUnicodeUnpack():
with raises(UnicodeDecodeError):
- unpackb(packb(b'abc\xeddef'), encoding='utf-8', use_list=1)
+ unpackb(packb(b'abc\xeddef'), raw_as_bytes=False, use_list=1)
-def testStrictUnicodePack():
+def testStrictUnicodePack(): # deprecated
with raises(UnicodeEncodeError):
packb("abc\xeddef", encoding='ascii', unicode_errors='strict')
-def testIgnoreErrorsPack():
- re = unpackb(packb("abcФФФdef", encoding='ascii', unicode_errors='ignore'), encoding='utf-8', use_list=1)
+def testIgnoreErrorsPack(): # deprecated
+ re = unpackb(packb("abcФФФdef", encoding='ascii', unicode_errors='ignore'), raw_as_bytes=False, use_list=1)
assert re == "abcdef"
-def testNoEncoding():
- with raises(TypeError):
- packb("abc", encoding=None)
-
def testDecodeBinary():
re = unpackb(packb(b"abc"), encoding=None, use_list=1)
assert re == b"abc"