bpo-40275: Use new test.support helper submodules in tests (GH-21449)

This commit is contained in:
Hai Shi 2020-08-04 00:41:24 +08:00 committed by GitHub
parent 488512bf49
commit a7f5d93bb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 154 additions and 132 deletions

View file

@ -4,7 +4,8 @@ import unittest
import binascii
import array
import re
from test import support
from test.support import warnings_helper
# Note: "*_hex" functions are aliases for "(un)hexlify"
b2a_functions = ['b2a_base64', 'b2a_hex', 'b2a_hqx', 'b2a_qp', 'b2a_uu',
@ -37,7 +38,7 @@ class BinASCIITest(unittest.TestCase):
self.assertTrue(hasattr(getattr(binascii, name), '__call__'))
self.assertRaises(TypeError, getattr(binascii, name))
@support.ignore_warnings(category=DeprecationWarning)
@warnings_helper.ignore_warnings(category=DeprecationWarning)
def test_returned_value(self):
# Limit to the minimum of all limits (b2a_uu)
MAX_ALL = 45
@ -181,7 +182,7 @@ class BinASCIITest(unittest.TestCase):
with self.assertRaises(TypeError):
binascii.b2a_uu(b"", True)
@support.ignore_warnings(category=DeprecationWarning)
@warnings_helper.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)
@ -201,7 +202,7 @@ class BinASCIITest(unittest.TestCase):
self.assertRaises(TypeError, binascii.crc32)
@support.ignore_warnings(category=DeprecationWarning)
@warnings_helper.ignore_warnings(category=DeprecationWarning)
def test_hqx(self):
# Perform binhex4 style RLE-compression
# Then calculate the hexbin4 binary-to-ASCII translation
@ -212,7 +213,7 @@ class BinASCIITest(unittest.TestCase):
res = binascii.rledecode_hqx(b)
self.assertEqual(res, self.rawdata)
@support.ignore_warnings(category=DeprecationWarning)
@warnings_helper.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)
@ -359,7 +360,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)
@warnings_helper.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'')
@ -384,7 +385,7 @@ class BinASCIITest(unittest.TestCase):
# crc_hqx needs 2 arguments
self.assertRaises(TypeError, binascii.crc_hqx, "test", 0)
@support.ignore_warnings(category=DeprecationWarning)
@warnings_helper.ignore_warnings(category=DeprecationWarning)
def test_unicode_a2b(self):
# Unicode strings are accepted by a2b_* functions.
MAX_ALL = 45