bpo-43405: Fix DeprecationWarnings in test_unicode (GH-24754)

DeprecationWarnings were being raised in the test_encode_decimal()
and test_transform_decimal() methods after 91a639a094.
This commit is contained in:
Zackery Spytz 2021-03-06 23:12:35 -07:00 committed by GitHub
parent 87ec26b812
commit 8aabfa8550
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2938,12 +2938,14 @@ class CAPITest(unittest.TestCase):
@support.requires_legacy_unicode_capi @support.requires_legacy_unicode_capi
def test_encode_decimal(self): def test_encode_decimal(self):
from _testcapi import unicode_encodedecimal from _testcapi import unicode_encodedecimal
with warnings_helper.check_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
self.assertEqual(unicode_encodedecimal('123'), self.assertEqual(unicode_encodedecimal('123'),
b'123') b'123')
self.assertEqual(unicode_encodedecimal('\u0663.\u0661\u0664'), self.assertEqual(unicode_encodedecimal('\u0663.\u0661\u0664'),
b'3.14') b'3.14')
self.assertEqual(unicode_encodedecimal("\N{EM SPACE}3.14\N{EN SPACE}"), self.assertEqual(unicode_encodedecimal(
b' 3.14 ') "\N{EM SPACE}3.14\N{EN SPACE}"), b' 3.14 ')
self.assertRaises(UnicodeEncodeError, self.assertRaises(UnicodeEncodeError,
unicode_encodedecimal, "123\u20ac", "strict") unicode_encodedecimal, "123\u20ac", "strict")
self.assertRaisesRegex( self.assertRaisesRegex(
@ -2955,6 +2957,8 @@ class CAPITest(unittest.TestCase):
@support.requires_legacy_unicode_capi @support.requires_legacy_unicode_capi
def test_transform_decimal(self): def test_transform_decimal(self):
from _testcapi import unicode_transformdecimaltoascii as transform_decimal from _testcapi import unicode_transformdecimaltoascii as transform_decimal
with warnings_helper.check_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
self.assertEqual(transform_decimal('123'), self.assertEqual(transform_decimal('123'),
'123') '123')
self.assertEqual(transform_decimal('\u0663.\u0661\u0664'), self.assertEqual(transform_decimal('\u0663.\u0661\u0664'),