Issue #25357: Add an optional newline paramer to binascii.b2a_base64().

base64.b64encode() uses it to avoid a memory copy.
This commit is contained in:
Victor Stinner 2015-10-11 11:01:02 +02:00
parent 5df7fddc0c
commit e84c976568
6 changed files with 45 additions and 20 deletions

View file

@ -262,6 +262,16 @@ class BinASCIITest(unittest.TestCase):
# non-ASCII string
self.assertRaises(ValueError, a2b, "\x80")
def test_b2a_base64_newline(self):
# Issue #25357: test newline parameter
b = self.type2test(b'hello')
self.assertEqual(binascii.b2a_base64(b),
b'aGVsbG8=\n')
self.assertEqual(binascii.b2a_base64(b, newline=True),
b'aGVsbG8=\n')
self.assertEqual(binascii.b2a_base64(b, newline=False),
b'aGVsbG8=')
class ArrayBinASCIITest(BinASCIITest):
def type2test(self, s):