22# coding: utf-8
33from __future__ import absolute_import , division , print_function , unicode_literals
44
5+ from collections import OrderedDict
6+ from io import BytesIO
57import struct
8+
9+ import pytest
610from pytest import raises , xfail
711
812from msgpack import packb , unpackb , Unpacker , Packer , pack
913
10- from collections import OrderedDict
11- from io import BytesIO
1214
1315def check (data , use_list = False ):
1416 re = unpackb (packb (data ), use_list = use_list )
@@ -47,7 +49,8 @@ def testPackUTF32(): # deprecated
4749 "Русский текст" ,
4850 ]
4951 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' )
5154 assert re == td
5255 except LookupError as e :
5356 xfail (e )
@@ -67,19 +70,23 @@ def testPackByteArrays():
6770 check (td )
6871
6972def 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 )
7175 assert re == "abcdef"
7276
7377def 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 )
7681
7782def testStrictUnicodePack (): # deprecated
7883 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' )
8086
8187def 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 )
8390 assert re == "abcdef"
8491
8592def testDecodeBinary ():
0 commit comments