6
6
import unittest
7
7
import binascii
8
8
import array
9
+ import sys
9
10
10
11
class MyInt ():
11
12
def __init__ (self , value ):
@@ -22,37 +23,42 @@ def test_b2a_base64_newline(self):
22
23
b = self .type2test (b'hello' )
23
24
self .assertEqual (binascii .b2a_base64 (b ),
24
25
b'aGVsbG8=\n ' )
25
- self .assertEqual (binascii .b2a_base64 (b , newline = True ),
26
+ if (sys .version_info .major >= 3 and sys .version_info .minor >= 6 ):
27
+ self .assertEqual (binascii .b2a_base64 (b , newline = True ),
26
28
b'aGVsbG8=\n ' )
27
- self .assertEqual (binascii .b2a_base64 (b , newline = False ),
29
+ self .assertEqual (binascii .b2a_base64 (b , newline = False ),
28
30
b'aGVsbG8=' )
29
31
30
32
def test_b2a_base64_int_newline (self ):
31
33
b = self .type2test (b'hello' )
32
- self .assertEqual (binascii .b2a_base64 (b , newline = 125 ),
34
+ if (sys .version_info .major >= 3 and sys .version_info .minor >= 6 ):
35
+ self .assertEqual (binascii .b2a_base64 (b , newline = 125 ),
33
36
b'aGVsbG8=\n ' )
34
- self .assertEqual (binascii .b2a_base64 (b , newline = - 10 ),
37
+ self .assertEqual (binascii .b2a_base64 (b , newline = - 10 ),
35
38
b'aGVsbG8=\n ' )
36
- self .assertEqual (binascii .b2a_base64 (b , newline = 0 ),
39
+ self .assertEqual (binascii .b2a_base64 (b , newline = 0 ),
37
40
b'aGVsbG8=' )
38
41
39
42
def test_b2a_base64_object_newline (self ):
40
43
b = self .type2test (b'hello' )
41
- self .assertEqual (binascii .b2a_base64 (b , newline = MyInt (125 )),
44
+ if (sys .version_info .major >= 3 and sys .version_info .minor >= 6 ):
45
+ self .assertEqual (binascii .b2a_base64 (b , newline = MyInt (125 )),
42
46
b'aGVsbG8=\n ' )
43
- self .assertEqual (binascii .b2a_base64 (b , newline = MyInt (- 10 )),
47
+ self .assertEqual (binascii .b2a_base64 (b , newline = MyInt (- 10 )),
44
48
b'aGVsbG8=\n ' )
45
- self .assertEqual (binascii .b2a_base64 (b , newline = MyInt (0 )),
49
+ self .assertEqual (binascii .b2a_base64 (b , newline = MyInt (0 )),
46
50
b'aGVsbG8=' )
47
51
48
52
def test_b2a_base64_wrong_newline (self ):
49
53
b = self .type2test (b'hello' )
50
- self .assertRaises (TypeError , binascii .b2a_base64 , b , newline = 'ahoj' )
54
+ if (sys .version_info .major >= 3 and sys .version_info .minor >= 6 ):
55
+ self .assertRaises (TypeError , binascii .b2a_base64 , b , newline = 'ahoj' )
51
56
52
57
def test_b2a_base64_return_type (self ):
53
58
b = self .type2test (b'hello' )
54
59
self .assertEqual (type (binascii .b2a_base64 (b )), bytes )
55
- self .assertEqual (type (binascii .b2a_base64 (b , newline = False )), bytes )
60
+ if (sys .version_info .major >= 3 and sys .version_info .minor >= 6 ):
61
+ self .assertEqual (type (binascii .b2a_base64 (b , newline = False )), bytes )
56
62
57
63
class ArrayBinASCIITest (BinASCIITest ):
58
64
def type2test (self , s ):
@@ -69,5 +75,6 @@ class MemoryviewBinASCIITest(BinASCIITest):
69
75
class IndependetTest (unittest .TestCase ):
70
76
71
77
def test_b2a_base64_wrong_first_arg (self ):
72
- self .assertRaises (TypeError , binascii .b2a_base64 , 'Ahoj' , newline = True )
73
- self .assertRaises (TypeError , binascii .b2a_base64 , 10 , newline = True )
78
+ if (sys .version_info .major >= 3 and sys .version_info .minor >= 6 ):
79
+ self .assertRaises (TypeError , binascii .b2a_base64 , 'Ahoj' , newline = True )
80
+ self .assertRaises (TypeError , binascii .b2a_base64 , 10 , newline = True )
0 commit comments