Changeset 391 for python/trunk/Lib/test/test_base64.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/test/test_base64.py
r2 r391 20 20 "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT" 21 21 "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==\n") 22 # Non-bytes 23 eq(base64.encodestring(bytearray('abc')), 'YWJj\n') 22 24 23 25 def test_decodestring(self): … … 34 36 "0123456789!@#0^&*();:<>,. []{}") 35 37 eq(base64.decodestring(''), '') 38 # Non-bytes 39 eq(base64.decodestring(bytearray("YWJj\n")), "abc") 36 40 37 41 def test_encode(self): … … 76 80 # Test with arbitrary alternative characters 77 81 eq(base64.b64encode('\xd3V\xbeo\xf7\x1d', altchars='*$'), '01a*b$cd') 82 # Non-bytes 83 eq(base64.b64encode(bytearray('abcd')), 'YWJjZA==') 84 self.assertRaises(TypeError, base64.b64encode, 85 '\xd3V\xbeo\xf7\x1d', altchars=bytearray('*$')) 78 86 # Test standard alphabet 79 87 eq(base64.standard_b64encode("www.python.org"), "d3d3LnB5dGhvbi5vcmc=") … … 88 96 "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NT" 89 97 "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==") 98 # Non-bytes 99 eq(base64.standard_b64encode(bytearray('abcd')), 'YWJjZA==') 90 100 # Test with 'URL safe' alternative characters 91 101 eq(base64.urlsafe_b64encode('\xd3V\xbeo\xf7\x1d'), '01a-b_cd') 102 # Non-bytes 103 eq(base64.urlsafe_b64encode(bytearray('\xd3V\xbeo\xf7\x1d')), '01a-b_cd') 92 104 93 105 def test_b64decode(self): … … 107 119 # Test with arbitrary alternative characters 108 120 eq(base64.b64decode('01a*b$cd', altchars='*$'), '\xd3V\xbeo\xf7\x1d') 121 # Non-bytes 122 eq(base64.b64decode(bytearray("YWJj")), "abc") 109 123 # Test standard alphabet 110 124 eq(base64.standard_b64decode("d3d3LnB5dGhvbi5vcmc="), "www.python.org") … … 119 133 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 120 134 "0123456789!@#0^&*();:<>,. []{}") 135 # Non-bytes 136 eq(base64.standard_b64decode(bytearray("YWJj")), "abc") 121 137 # Test with 'URL safe' alternative characters 122 138 eq(base64.urlsafe_b64decode('01a-b_cd'), '\xd3V\xbeo\xf7\x1d') 139 # Non-bytes 140 eq(base64.urlsafe_b64decode(bytearray('01a-b_cd')), '\xd3V\xbeo\xf7\x1d') 123 141 124 142 def test_b64decode_error(self): … … 134 152 eq(base64.b32encode('abcd'), 'MFRGGZA=') 135 153 eq(base64.b32encode('abcde'), 'MFRGGZDF') 154 # Non-bytes 155 eq(base64.b32encode(bytearray('abcd')), 'MFRGGZA=') 136 156 137 157 def test_b32decode(self): … … 144 164 eq(base64.b32decode('MFRGGZA='), 'abcd') 145 165 eq(base64.b32decode('MFRGGZDF'), 'abcde') 166 # Non-bytes 167 self.assertRaises(TypeError, base64.b32decode, bytearray('MFRGG===')) 146 168 147 169 def test_b32decode_casefold(self): … … 174 196 eq(base64.b16encode('\x01\x02\xab\xcd\xef'), '0102ABCDEF') 175 197 eq(base64.b16encode('\x00'), '00') 198 # Non-bytes 199 eq(base64.b16encode(bytearray('\x01\x02\xab\xcd\xef')), '0102ABCDEF') 176 200 177 201 def test_b16decode(self): … … 183 207 # Case fold 184 208 eq(base64.b16decode('0102abcdef', True), '\x01\x02\xab\xcd\xef') 209 # Non-bytes 210 eq(base64.b16decode(bytearray("0102ABCDEF")), '\x01\x02\xab\xcd\xef') 185 211 186 212
Note:
See TracChangeset
for help on using the changeset viewer.