@@ -69,31 +69,17 @@ def _capture_unraisable_hook(ur_args):
6969assert __version__ == "2.2.0.dev0" , ("This test_c.py file is for testing a version"
7070 " of cffi that differs from the one that we"
7171 " get from 'import _cffi_backend'" )
72- if sys .version_info < (3 ,):
73- type_or_class = "type"
74- mandatory_b_prefix = ''
75- mandatory_u_prefix = 'u'
76- bytechr = chr
77- bitem2bchr = lambda x : x
78- class U :
79- def __add__ (self , other ):
80- return eval ('u' + repr (other ).replace (r'\\u' , r'\u' )
81- .replace (r'\\U' , r'\U' ))
82- u = U ()
83- str2bytes = str
84- strict_compare = False
85- else :
86- type_or_class = "class"
87- long = int
88- unicode = str
89- unichr = chr
90- mandatory_b_prefix = 'b'
91- mandatory_u_prefix = ''
92- bytechr = lambda n : bytes ([n ])
93- bitem2bchr = bytechr
94- u = ""
95- str2bytes = lambda s : bytes (s , "ascii" )
96- strict_compare = True
72+ type_or_class = "class"
73+ long = int
74+ unicode = str
75+ unichr = chr
76+ mandatory_b_prefix = 'b'
77+ mandatory_u_prefix = ''
78+ bytechr = lambda n : bytes ([n ])
79+ bitem2bchr = bytechr
80+ u = ""
81+ str2bytes = lambda s : bytes (s , "ascii" )
82+ strict_compare = True
9783
9884def size_of_int ():
9985 BInt = new_primitive_type ("int" )
@@ -1687,10 +1673,6 @@ def test_enum_in_struct():
16871673 "expected integer, got NoneType object" in msg ) # newer PyPys
16881674 with pytest .raises (TypeError ):
16891675 p .a1 = "def"
1690- if sys .version_info < (3 ,):
1691- BEnum2 = new_enum_type (unicode ("foo" ), (unicode ('abc' ),), (5 ,), BInt )
1692- assert string (cast (BEnum2 , 5 )) == 'abc'
1693- assert type (string (cast (BEnum2 , 5 ))) is str
16941676
16951677def test_enum_overflow ():
16961678 max_uint = 2 ** (size_of_int ()* 8 ) - 1
@@ -2485,11 +2467,7 @@ def test_buffer():
24852467 assert repr (buf ).startswith ('<_cffi_backend.buffer object at 0x' )
24862468 assert bytes (buf ) == b"hi there\x00 "
24872469 assert type (buf ) is buffer
2488- if sys .version_info < (3 ,):
2489- assert str (buf ) == "hi there\x00 "
2490- assert unicode (buf ) == u + "hi there\x00 "
2491- else :
2492- assert str (buf ) == repr (buf )
2470+ assert str (buf ) == repr (buf )
24932471 # --mb_length--
24942472 assert len (buf ) == len (b"hi there\x00 " )
24952473 # --mb_item--
@@ -3015,12 +2993,11 @@ def test_string_assignment_to_byte_array():
30152993 assert list (p ) == [ord ("X" ), ord ("Y" ), ord ("Z" ), 0 , 0 ]
30162994
30172995# XXX hack
3018- if sys .version_info >= (3 ,):
3019- try :
3020- import posix
3021- posix .fdopen = open
3022- except ImportError :
3023- pass # win32
2996+ try :
2997+ import posix
2998+ posix .fdopen = open
2999+ except ImportError :
3000+ pass # win32
30243001
30253002@pytest .mark .skipif (
30263003 is_ios ,
@@ -3838,16 +3815,14 @@ def test_from_buffer_more_cases():
38383815 def check1 (bufobj , expected ):
38393816 c = from_buffer (BCharA , bufobj )
38403817 assert typeof (c ) is BCharA
3841- if sys .version_info >= (3 ,):
3842- expected = [bytes (c , "ascii" ) for c in expected ]
3818+ expected = [bytes (c , "ascii" ) for c in expected ]
38433819 assert list (c ) == list (expected )
38443820 #
38453821 def check (methods , expected , expected_for_memoryview = None ):
3846- if sys .version_info >= (3 ,):
3847- if methods <= 7 :
3848- return
3849- if expected_for_memoryview is not None :
3850- expected = expected_for_memoryview
3822+ if methods <= 7 :
3823+ return
3824+ if expected_for_memoryview is not None :
3825+ expected = expected_for_memoryview
38513826 class X :
38523827 pass
38533828 _testbuff (X , methods )
0 commit comments