diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-01-13 09:42:17 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-01-13 09:42:17 +0200 |
commit | c5134c83efd1055ea4a9f3680ff29d0d71cd11f7 (patch) | |
tree | b3ec57c060e32f0154d81d455a8eeecb53e8f1a0 /Lib/test/test_binascii.py | |
parent | edc597f4d8d524c57fd62e9153525ff5be7aed1d (diff) | |
parent | cea403188c49d053e716a0b1b07a99a5f1331d9d (diff) | |
download | cpython-c5134c83efd1055ea4a9f3680ff29d0d71cd11f7.tar.gz |
Issue #29219: Fixed infinite recursion in the repr of uninitialized
ctypes.CDLL instances.
Diffstat (limited to 'Lib/test/test_binascii.py')
-rw-r--r-- | Lib/test/test_binascii.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/Lib/test/test_binascii.py b/Lib/test/test_binascii.py index 034245d74e..6b3e437f43 100644 --- a/Lib/test/test_binascii.py +++ b/Lib/test/test_binascii.py @@ -159,11 +159,25 @@ class BinASCIITest(unittest.TestCase): # Then calculate the hexbin4 binary-to-ASCII translation rle = binascii.rlecode_hqx(self.data) a = binascii.b2a_hqx(self.type2test(rle)) + b, _ = binascii.a2b_hqx(self.type2test(a)) res = binascii.rledecode_hqx(b) - self.assertEqual(res, self.rawdata) + def test_rle(self): + # test repetition with a repetition longer than the limit of 255 + data = (b'a' * 100 + b'b' + b'c' * 300) + + encoded = binascii.rlecode_hqx(data) + self.assertEqual(encoded, + (b'a\x90d' # 'a' * 100 + b'b' # 'b' + b'c\x90\xff' # 'c' * 255 + b'c\x90-')) # 'c' * 45 + + decoded = binascii.rledecode_hqx(encoded) + self.assertEqual(decoded, data) + def test_hex(self): # test hexlification s = b'{s\005\000\000\000worldi\002\000\000\000s\005\000\000\000helloi\001\000\000\0000' @@ -331,6 +345,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): |