Issue #22088: Port base64 character ignoring doc and test from 857d9fe60169
diff --git a/Lib/test/test_base64.py b/Lib/test/test_base64.py
index 3f2cee4..5dd283b 100644
--- a/Lib/test/test_base64.py
+++ b/Lib/test/test_base64.py
@@ -137,9 +137,23 @@
# Non-bytes
eq(base64.urlsafe_b64decode(bytearray('01a-b_cd')), '\xd3V\xbeo\xf7\x1d')
- def test_b64decode_error(self):
+ def test_b64decode_padding_error(self):
self.assertRaises(TypeError, base64.b64decode, 'abc')
+ def test_b64decode_invalid_chars(self):
+ # issue 1466065: Test some invalid characters.
+ tests = ((b'%3d==', b'\xdd'),
+ (b'$3d==', b'\xdd'),
+ (b'[==', b''),
+ (b'YW]3=', b'am'),
+ (b'3{d==', b'\xdd'),
+ (b'3d}==', b'\xdd'),
+ (b'@@', b''),
+ (b'!', b''),
+ (b'YWJj\nYWI=', b'abcab'))
+ for bstr, res in tests:
+ self.assertEqual(base64.b64decode(bstr), res)
+
def test_b32encode(self):
eq = self.assertEqual
eq(base64.b32encode(''), '')