mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
5df7fddc0c
commit
e84c976568
6 changed files with 45 additions and 20 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue