diff options
author | Zackery Spytz <zspytz@gmail.com> | 2021-03-07 06:12:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-07 06:12:35 (GMT) |
commit | 8aabfa8550692a76d8a96e138c48faf5a7b2752c (patch) | |
tree | 594afd851cac2136472f60df220466f140ad0013 /Lib/test/test_unicode.py | |
parent | 87ec26b812e9c4095c017dc60f246eda37b83ab2 (diff) | |
download | cpython-8aabfa8550692a76d8a96e138c48faf5a7b2752c.zip cpython-8aabfa8550692a76d8a96e138c48faf5a7b2752c.tar.gz cpython-8aabfa8550692a76d8a96e138c48faf5a7b2752c.tar.bz2 |
bpo-43405: Fix DeprecationWarnings in test_unicode (GH-24754)
DeprecationWarnings were being raised in the test_encode_decimal()
and test_transform_decimal() methods after 91a639a0949.
Diffstat (limited to 'Lib/test/test_unicode.py')
-rw-r--r-- | Lib/test/test_unicode.py | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 2626be6..42c77f0 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -2938,31 +2938,35 @@ class CAPITest(unittest.TestCase): @support.requires_legacy_unicode_capi def test_encode_decimal(self): from _testcapi import unicode_encodedecimal - self.assertEqual(unicode_encodedecimal('123'), - b'123') - self.assertEqual(unicode_encodedecimal('\u0663.\u0661\u0664'), - b'3.14') - self.assertEqual(unicode_encodedecimal("\N{EM SPACE}3.14\N{EN SPACE}"), - b' 3.14 ') - self.assertRaises(UnicodeEncodeError, - unicode_encodedecimal, "123\u20ac", "strict") - self.assertRaisesRegex( - ValueError, - "^'decimal' codec can't encode character", - unicode_encodedecimal, "123\u20ac", "replace") + with warnings_helper.check_warnings(): + warnings.simplefilter('ignore', DeprecationWarning) + self.assertEqual(unicode_encodedecimal('123'), + b'123') + self.assertEqual(unicode_encodedecimal('\u0663.\u0661\u0664'), + b'3.14') + self.assertEqual(unicode_encodedecimal( + "\N{EM SPACE}3.14\N{EN SPACE}"), b' 3.14 ') + self.assertRaises(UnicodeEncodeError, + unicode_encodedecimal, "123\u20ac", "strict") + self.assertRaisesRegex( + ValueError, + "^'decimal' codec can't encode character", + unicode_encodedecimal, "123\u20ac", "replace") @support.cpython_only @support.requires_legacy_unicode_capi def test_transform_decimal(self): from _testcapi import unicode_transformdecimaltoascii as transform_decimal - self.assertEqual(transform_decimal('123'), - '123') - self.assertEqual(transform_decimal('\u0663.\u0661\u0664'), - '3.14') - self.assertEqual(transform_decimal("\N{EM SPACE}3.14\N{EN SPACE}"), - "\N{EM SPACE}3.14\N{EN SPACE}") - self.assertEqual(transform_decimal('123\u20ac'), - '123\u20ac') + with warnings_helper.check_warnings(): + warnings.simplefilter('ignore', DeprecationWarning) + self.assertEqual(transform_decimal('123'), + '123') + self.assertEqual(transform_decimal('\u0663.\u0661\u0664'), + '3.14') + self.assertEqual(transform_decimal("\N{EM SPACE}3.14\N{EN SPACE}"), + "\N{EM SPACE}3.14\N{EN SPACE}") + self.assertEqual(transform_decimal('123\u20ac'), + '123\u20ac') @support.cpython_only def test_pep393_utf8_caching_bug(self): |