11#!/usr/bin/env python
22# coding: utf-8
3+ from __future__ import absolute_import , division , print_function , unicode_literals
34
4- import six
55import struct
66from pytest import raises , xfail
77
@@ -28,24 +28,22 @@ def testPack():
2828 check (td )
2929
3030def testPackUnicode ():
31- test_data = [
32- six .u ("" ), six .u ("abcd" ), [six .u ("defgh" )], six .u ("Русский текст" ),
33- ]
31+ test_data = ["" , "abcd" , ["defgh" ], "Русский текст" ]
3432 for td in test_data :
3533 re = unpackb (packb (td , encoding = 'utf-8' ), use_list = 1 , encoding = 'utf-8' )
3634 assert re == td
3735 packer = Packer (encoding = 'utf-8' )
3836 data = packer .pack (td )
39- re = Unpacker (BytesIO (data ), encoding = 'utf-8' , use_list = 1 ).unpack ()
37+ re = Unpacker (BytesIO (data ), encoding = str ( 'utf-8' ) , use_list = 1 ).unpack ()
4038 assert re == td
4139
4240def testPackUTF32 ():
4341 try :
4442 test_data = [
45- six . u ( "" ) ,
46- six . u ( "abcd" ) ,
47- [six . u ( "defgh" ) ],
48- six . u ( "Русский текст" ) ,
43+ "" ,
44+ "abcd" ,
45+ ["defgh" ],
46+ "Русский текст" ,
4947 ]
5048 for td in test_data :
5149 re = unpackb (packb (td , encoding = 'utf-32' ), use_list = 1 , encoding = 'utf-32' )
@@ -70,23 +68,23 @@ def testStrictUnicodeUnpack():
7068
7169def testStrictUnicodePack ():
7270 with raises (UnicodeEncodeError ):
73- packb (six . u ( "abc\xed def" ) , encoding = 'ascii' , unicode_errors = 'strict' )
71+ packb ("abc\xed def" , encoding = 'ascii' , unicode_errors = 'strict' )
7472
7573def testIgnoreErrorsPack ():
76- re = unpackb (packb (six . u ( "abcФФФdef" ) , encoding = 'ascii' , unicode_errors = 'ignore' ), encoding = 'utf-8' , use_list = 1 )
77- assert re == six . u ( "abcdef" )
74+ re = unpackb (packb ("abcФФФdef" , encoding = 'ascii' , unicode_errors = 'ignore' ), encoding = 'utf-8' , use_list = 1 )
75+ assert re == "abcdef"
7876
7977def testNoEncoding ():
8078 with raises (TypeError ):
81- packb (six . u ( "abc" ) , encoding = None )
79+ packb ("abc" , encoding = None )
8280
8381def testDecodeBinary ():
84- re = unpackb (packb ("abc" ), encoding = None , use_list = 1 )
82+ re = unpackb (packb (b "abc" ), encoding = None , use_list = 1 )
8583 assert re == b"abc"
8684
8785def testPackFloat ():
88- assert packb (1.0 , use_single_float = True ) == b'\xca ' + struct .pack ('>f' , 1.0 )
89- assert packb (1.0 , use_single_float = False ) == b'\xcb ' + struct .pack ('>d' , 1.0 )
86+ assert packb (1.0 , use_single_float = True ) == b'\xca ' + struct .pack (str ( '>f' ) , 1.0 )
87+ assert packb (1.0 , use_single_float = False ) == b'\xcb ' + struct .pack (str ( '>d' ) , 1.0 )
9088
9189def testArraySize (sizes = [0 , 5 , 50 , 1000 ]):
9290 bio = BytesIO ()
0 commit comments