8000 Fix warnings in tests. · peter80/msgpack-python@c280e58 · GitHub
[go: up one dir, main page]

Skip to content

Commit c280e58

Browse files
committed
Fix warnings in tests.
1 parent d503788 commit c280e58

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

test/test_case.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
def check(length, obj):
1010
v = packb(obj)
1111
assert_equal(len(v), length, "%r length should be %r but get %r" % (obj, length, len(v)))
12-
assert_equal(unpackb(v), obj)
12+
assert_equal(unpackb(v, use_list=0), obj)
1313

1414
def test_1():
1515
for o in [None, True, False, 0, 1, (1 << 6), (1 << 7) - 1, -1,
@@ -71,7 +71,7 @@ def test_array32():
7171

7272
def match(obj, buf):
7373
assert_equal(packb(obj), buf)
74-
assert_equal(unpackb(buf), obj)
74+
assert_equal(unpackb(buf, use_list=0), obj)
7575

7676
def test_match():
7777
cases = [
@@ -99,7 +99,7 @@ def test_match():
9999
match(v, p)
100100

101101
def test_unicode():
102-
assert_equal(b'foobar', unpackb(packb('foobar')))
102+
assert_equal(b'foobar', unpackb(packb('foobar'), use_list=1))
103103

104104
if __name__ == '__main__':
105105
main()

test/test_obj.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,25 @@ def _encode_complex(obj):
1818

1919
def test_encode_hook():
2020
packed = packb([3, 1+2j], default=_encode_complex)
21-
unpacked = unpackb(packed)
21+
unpacked = unpackb(packed, use_list=1)
2222
eq_(unpacked[1], {b'__complex__': True, b'real': 1, b'imag': 2})
2323

2424
def test_decode_hook():
2525
packed = packb([3, {b'__complex__': True, b'real': 1, b'imag': 2}])
26-
unpacked = unpackb(packed, object_hook=_decode_complex)
26+
unpacked = unpackb(packed, object_hook=_decode_complex, use_list=1)
2727
eq_(unpacked[1], 1+2j)
2828

2929
@raises(ValueError)
3030
def test_bad_hook():
3131
packed = packb([3, 1+2j], default=lambda o: o)
32-
unpacked = unpackb(packed)
32+
unpacked = unpackb(packed, use_list=1)
3333

3434
def _arr_to_str(arr):
3535
return ''.join(str(c) for c in arr)
3636

3737
def test_array_hook():
3838
packed = packb([1,2,3])
39-
unpacked = unpackb(packed, list_hook=_arr_to_str)
39+
unpacked = unpackb(packed, list_hook=_arr_to_str, use_list=1)
4040
eq_(unpacked, '123')
4141

4242
if __name__ == '__main__':

test/test_pack.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ def testPack():
3131

3232
def testPackUnicode():
3333
test_data = [
34-
six.u(""), six.u("abcd"), (six.u("defgh"),), six.u("Русский текст"),
34+
six.u(""), six.u("abcd"), [six.u("defgh")], six.u("Русский текст"),
3535
]
3636
for td in test_data:
37-
re = unpackb(packb(td, encoding='utf-8'), use_list=0, encoding='utf-8')
37+
re = unpackb(packb(td, encoding='utf-8'), use_list=1, encoding='utf-8')
3838
assert_equal(re, td)
3939
packer = Packer(encoding='utf-8')
4040
data = packer.pack(td)
41-
re = Unpacker(BytesIO(data), encoding='utf-8').unpack()
41+
re = Unpacker(BytesIO(data), encoding='utf-8', use_list=1).unpack()
4242
assert_equal(re, td)
4343

4444
def testPackUTF32():
@@ -63,28 +63,27 @@ def testPackBytes():
6363
check(td)
6464

6565
def testIgnoreUnicodeErrors():
66-
re = unpackb(packb(b'abc\xeddef'),
67-
encoding='utf-8', unicode_errors='ignore')
66+
re = unpackb(packb(b'abc\xeddef'), encoding='utf-8', unicode_errors='ignore', use_list=1)
6867
assert_equal(re, "abcdef")
6968

7069
@raises(UnicodeDecodeError)
7170
def testStrictUnicodeUnpack():
72-
unpackb(packb(b'abc\xeddef'), encoding='utf-8')
71+
unpackb(packb(b'abc\xeddef'), encoding='utf-8', use_list=1)
7372

7473
@raises(UnicodeEncodeError)
7574
def testStrictUnicodePack():
7675
packb(six.u("abc\xeddef"), encoding='ascii', unicode_errors='strict')
7776

7877
def testIgnoreErrorsPack():
79-
re = unpackb(packb(six.u("abcФФФdef"), encoding='ascii', unicode_errors='ignore'), encoding='utf-8')
78+
re = unpackb(packb(six.u("abcФФФdef"), encoding='ascii', unicode_errors='ignore'), encoding='utf-8', use_list=1)
8079
assert_equal(re, six.u("abcdef"))
8180

8281
@raises(TypeError)
8382
def testNoEncoding():
8483
packb(six.u("abc"), encoding=None)
8584

8685
def testDecodeBinary():
87-
re = unpackb(packb("abc"), encoding=None)
86+
re = unpackb(packb("abc"), encoding=None, use_list=1)
8887
assert_equal(re, b"abc")
8988

9089
def testPackFloat():

0 commit comments

Comments
 (0)
0