summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_binascii.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-10-11 09:01:02 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-10-11 09:01:02 (GMT)
commite84c97656899750a8e6b01bef2cfc01b31d60220 (patch)
treedf461163e3ade56701a5844d1b1b47e29c887f9f /Lib/test/test_binascii.py
parent5df7fddc0c678f10ae6f9995c516dd7091fd6cbc (diff)
downloadcpython-e84c97656899750a8e6b01bef2cfc01b31d60220.zip
cpython-e84c97656899750a8e6b01bef2cfc01b31d60220.tar.gz
cpython-e84c97656899750a8e6b01bef2cfc01b31d60220.tar.bz2
Issue #25357: Add an optional newline paramer to binascii.b2a_base64().
base64.b64encode() uses it to avoid a memory copy.
Diffstat (limited to 'Lib/test/test_binascii.py')
-rw-r--r--Lib/test/test_binascii.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_binascii.py b/Lib/test/test_binascii.py
index 8367afe..0ab46bc 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):