2
2
# coding: utf-8
3
3
from __future__ import absolute_import , division , print_function , unicode_literals
4
4
5
+ from collections import OrderedDict
6
+ from io import BytesIO
5
7
import struct
8
+
9
+ import pytest
6
10
from pytest import raises , xfail
7
11
8
12
from msgpack import packb , unpackb , Unpacker , Packer , pack
9
13
10
- from collections import OrderedDict
11
- from io import BytesIO
12
14
13
15
def check (data , use_list = False ):
14
16
re = unpackb (packb (data ), use_list = use_list )
@@ -47,7 +49,8 @@ def testPackUTF32(): # deprecated
47
49
"Русский текст" ,
48
50
]
49
51
for td in test_data :
50
- re = unpackb (packb (td , encoding = 'utf-32' ), use_list = 1 , encoding = 'utf-32' )
52
+ with pytest .deprecated_call ():
53
+ re = unpackb (packb (td , encoding = 'utf-32' ), use_list = 1 , encoding = 'utf-32' )
51
54
assert re == td
52
55
except LookupError as e :
53
56
xfail (e )
@@ -67,19 +70,23 @@ def testPackByteArrays():
67
70
check (td )
68
71
69
72
def testIgnoreUnicodeErrors (): # deprecated
70
- re = unpackb (packb (b'abc\xed def' ), encoding = 'utf-8' , unicode_errors = 'ignore' , use_list = 1 )
73
+ with pytest .deprecated_call ():
74
+ re = unpackb (packb (b'abc\xed def' ), encoding = 'utf-8' , unicode_errors = 'ignore' , use_list = 1 )
71
75
assert re == "abcdef"
72
76
73
77
def testStrictUnicodeUnpack ():
74
- with raises (UnicodeDecodeError ):
75
- unpackb (packb (b'abc\xed def' ), raw = False , use_list = 1 )
78
+ packed = packb (b'abc\xed def' )
79
+ with pytest .raises (UnicodeDecodeError ):
80
+ unpackb (packed , raw = False , use_list = 1 )
76
81
77
82
def testStrictUnicodePack (): # deprecated
78
83
with raises (UnicodeEncodeError ):
79
- packb ("abc\xed def" , encoding = 'ascii' , unicode_errors = 'strict' )
84
+ with pytest .deprecated_call ():
85
+ packb ("abc\xed def" , encoding = 'ascii' , unicode_errors = 'strict' )
80
86
81
87
def testIgnoreErrorsPack (): # deprecated
82
- re = unpackb (packb ("abcФФФdef" , encoding = 'ascii' , unicode_errors = 'ignore' ), raw = False , use_list = 1 )
88
+ with pytest .deprecated_call ():
89
+ re = unpackb (packb ("abcФФФdef" , encoding = 'ascii' , unicode_errors = 'ignore' ), raw = False , use_list = 1 )
83
90
assert re == "abcdef"
84
91
85
92
def testDecodeBinary ():
0 commit comments