From e84c97656899750a8e6b01bef2cfc01b31d60220 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sun, 11 Oct 2015 11:01:02 +0200 Subject: Issue #25357: Add an optional newline paramer to binascii.b2a_base64(). base64.b64encode() uses it to avoid a memory copy. --- Lib/test/test_binascii.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Lib/test/test_binascii.py') diff --git a/Lib/test/test_binascii.py b/Lib/test/test_binascii.py index 8367afe083..0ab46bc3f3 100644 --- a/Lib/test/test_binascii.py +++ b/Lib/test/test_binascii.py @@ -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): -- cgit v1.2.1