diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-01-25 13:25:52 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-01-25 13:25:52 +0200 |
commit | 3f19a274c28567afb39ba46ea8a2ebdeab816b0b (patch) | |
tree | b455925dd27f3d6e421d9fca9f3295b988a24254 /Lib/test/test_binascii.py | |
parent | b0cbde5d42f12b3aca11b87c017b3c60a26be4fd (diff) | |
parent | c8486579312320fd09c56ce9fce3da7ea0ffd132 (diff) | |
download | cpython-3f19a274c28567afb39ba46ea8a2ebdeab816b0b.tar.gz |
Issue #27867: Function PySlice_GetIndicesEx() is replaced with a macro if
Py_LIMITED_API is not set or set to the value between 0x03050400
and 0x03060000 (not including) or 0x03060100 or higher.
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): |