Skip to content

Commit 6c33ebb

Browse files
committed
Add test for coverage of _85buffer_iter_words for large inputs
1 parent 39b1d7e commit 6c33ebb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Lib/test/test_base64.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import unittest
22
import base64
33
import binascii
4+
import hashlib
5+
import string
46
import os
57
from array import array
68
from test.support import os_helper
@@ -545,6 +547,17 @@ def test_b85encode(self):
545547
self.check_other_types(base64.b85encode, b"www.python.org",
546548
b'cXxL#aCvlSZ*DGca%T')
547549

550+
def test_b85encode_large_input(self):
551+
# more than 512 bytes (+ padding)
552+
large_input = string.ascii_letters.encode() * 12 + b"foo"
553+
result = base64.b85encode(large_input)
554+
555+
# since the result is to large to fit inside a test,
556+
# use a hash method to validate the test
557+
self.assertEqual(len(result), 784)
558+
self.assertEqual(hashlib.md5(result).hexdigest(),
559+
"0537cfca1aed7495e80d3328e9ef3008")
560+
548561
def test_a85decode(self):
549562
eq = self.assertEqual
550563

0 commit comments

Comments
 (0)