diff options
author | Victor Stinner <vstinner@python.org> | 2020-01-22 20:44:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-22 20:44:22 +0100 |
commit | beea26b57e8c80f1eff0f967a0f9d083a7dc3d66 (patch) | |
tree | 473ad7cfdd3e65177dc7e392152759bba38e5826 /Lib/test/test_binascii.py | |
parent | 14d80d0b605d8b148e14458e4c1853a940071462 (diff) | |
download | cpython-git-beea26b57e8c80f1eff0f967a0f9d083a7dc3d66.tar.gz |
bpo-39353: Deprecate the binhex module (GH-18025)
Deprecate binhex4 and hexbin4 standards. Deprecate the binhex module
and the following binascii functions:
* b2a_hqx(), a2b_hqx()
* rlecode_hqx(), rledecode_hqx()
* crc_hqx()
Diffstat (limited to 'Lib/test/test_binascii.py')
-rw-r--r-- | Lib/test/test_binascii.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_binascii.py b/Lib/test/test_binascii.py index 08de5c9fc7..649edbe295 100644 --- a/Lib/test/test_binascii.py +++ b/Lib/test/test_binascii.py @@ -4,6 +4,7 @@ import unittest import binascii import array import re +from test import support # Note: "*_hex" functions are aliases for "(un)hexlify" b2a_functions = ['b2a_base64', 'b2a_hex', 'b2a_hqx', 'b2a_qp', 'b2a_uu', @@ -36,6 +37,7 @@ class BinASCIITest(unittest.TestCase): self.assertTrue(hasattr(getattr(binascii, name), '__call__')) self.assertRaises(TypeError, getattr(binascii, name)) + @support.ignore_warnings(category=DeprecationWarning) def test_returned_value(self): # Limit to the minimum of all limits (b2a_uu) MAX_ALL = 45 @@ -179,6 +181,7 @@ class BinASCIITest(unittest.TestCase): with self.assertRaises(TypeError): binascii.b2a_uu(b"", True) + @support.ignore_warnings(category=DeprecationWarning) def test_crc_hqx(self): crc = binascii.crc_hqx(self.type2test(b"Test the CRC-32 of"), 0) crc = binascii.crc_hqx(self.type2test(b" this string."), crc) @@ -198,6 +201,7 @@ class BinASCIITest(unittest.TestCase): self.assertRaises(TypeError, binascii.crc32) + @support.ignore_warnings(category=DeprecationWarning) def test_hqx(self): # Perform binhex4 style RLE-compression # Then calculate the hexbin4 binary-to-ASCII translation @@ -208,6 +212,7 @@ class BinASCIITest(unittest.TestCase): res = binascii.rledecode_hqx(b) self.assertEqual(res, self.rawdata) + @support.ignore_warnings(category=DeprecationWarning) def test_rle(self): # test repetition with a repetition longer than the limit of 255 data = (b'a' * 100 + b'b' + b'c' * 300) @@ -354,6 +359,7 @@ class BinASCIITest(unittest.TestCase): self.assertEqual(b2a_qp(type2test(b'a.\n')), b'a.\n') self.assertEqual(b2a_qp(type2test(b'.a')[:-1]), b'=2E') + @support.ignore_warnings(category=DeprecationWarning) def test_empty_string(self): # A test for SF bug #1022953. Make sure SystemError is not raised. empty = self.type2test(b'') @@ -378,6 +384,7 @@ class BinASCIITest(unittest.TestCase): # crc_hqx needs 2 arguments self.assertRaises(TypeError, binascii.crc_hqx, "test", 0) + @support.ignore_warnings(category=DeprecationWarning) def test_unicode_a2b(self): # Unicode strings are accepted by a2b_* functions. MAX_ALL = 45 @@ -416,6 +423,21 @@ class BinASCIITest(unittest.TestCase): self.assertEqual(binascii.b2a_base64(b, newline=False), b'aGVsbG8=') + def test_deprecated_warnings(self): + with self.assertWarns(DeprecationWarning): + self.assertEqual(binascii.b2a_hqx(b'abc'), b'B@*M') + with self.assertWarns(DeprecationWarning): + self.assertEqual(binascii.a2b_hqx(b'B@*M'), (b'abc', 0)) + + with self.assertWarns(DeprecationWarning): + self.assertEqual(binascii.rlecode_hqx(b'a' * 10), b'a\x90\n') + + with self.assertWarns(DeprecationWarning): + self.assertEqual(binascii.rledecode_hqx(b'a\x90\n'), b'a' * 10) + + with self.assertWarns(DeprecationWarning): + self.assertEqual(binascii.crc_hqx(b'abc', 0), 40406) + class ArrayBinASCIITest(BinASCIITest): def type2test(self, s): |