diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-10-14 13:02:35 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-10-14 13:02:35 (GMT) |
commit | 1bfe9305859cf280464ed1f40fc9e2793b0f03b7 (patch) | |
tree | 0263e5bdceb6457ed61bbbde654f8845cd0553f0 /Lib/test/test_binascii.py | |
parent | c3d2bc19e47892e19c9ad6a048047964dbb78cb6 (diff) | |
download | cpython-1bfe9305859cf280464ed1f40fc9e2793b0f03b7.zip cpython-1bfe9305859cf280464ed1f40fc9e2793b0f03b7.tar.gz cpython-1bfe9305859cf280464ed1f40fc9e2793b0f03b7.tar.bz2 |
Issue #25384: Fix binascii.rledecode_hqx()
Fix usage of _PyBytesWriter API. Use the new _PyBytesWriter_Resize() function
instead of _PyBytesWriter_Prepare().
Diffstat (limited to 'Lib/test/test_binascii.py')
-rw-r--r-- | Lib/test/test_binascii.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Lib/test/test_binascii.py b/Lib/test/test_binascii.py index 0ab46bc..fbc933e4 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' |