mirror of
https://github.com/python/cpython.git
synced 2025-11-02 19:12:55 +00:00
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:
parent
87ec26b812
commit
8aabfa8550
1 changed files with 24 additions and 20 deletions
|
|
@ -2938,31 +2938,35 @@ 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
|
||||||
self.assertEqual(unicode_encodedecimal('123'),
|
with warnings_helper.check_warnings():
|
||||||
b'123')
|
warnings.simplefilter('ignore', DeprecationWarning)
|
||||||
self.assertEqual(unicode_encodedecimal('\u0663.\u0661\u0664'),
|
self.assertEqual(unicode_encodedecimal('123'),
|
||||||
b'3.14')
|
b'123')
|
||||||
self.assertEqual(unicode_encodedecimal("\N{EM SPACE}3.14\N{EN SPACE}"),
|
self.assertEqual(unicode_encodedecimal('\u0663.\u0661\u0664'),
|
||||||
b' 3.14 ')
|
b'3.14')
|
||||||
self.assertRaises(UnicodeEncodeError,
|
self.assertEqual(unicode_encodedecimal(
|
||||||
unicode_encodedecimal, "123\u20ac", "strict")
|
"\N{EM SPACE}3.14\N{EN SPACE}"), b' 3.14 ')
|
||||||
self.assertRaisesRegex(
|
self.assertRaises(UnicodeEncodeError,
|
||||||
ValueError,
|
unicode_encodedecimal, "123\u20ac", "strict")
|
||||||
"^'decimal' codec can't encode character",
|
self.assertRaisesRegex(
|
||||||
unicode_encodedecimal, "123\u20ac", "replace")
|
ValueError,
|
||||||
|
"^'decimal' codec can't encode character",
|
||||||
|
unicode_encodedecimal, "123\u20ac", "replace")
|
||||||
|
|
||||||
@support.cpython_only
|
@support.cpython_only
|
||||||
@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
|
||||||
self.assertEqual(transform_decimal('123'),
|
with warnings_helper.check_warnings():
|
||||||
'123')
|
warnings.simplefilter('ignore', DeprecationWarning)
|
||||||
self.assertEqual(transform_decimal('\u0663.\u0661\u0664'),
|
self.assertEqual(transform_decimal('123'),
|
||||||
'3.14')
|
'123')
|
||||||
self.assertEqual(transform_decimal("\N{EM SPACE}3.14\N{EN SPACE}"),
|
self.assertEqual(transform_decimal('\u0663.\u0661\u0664'),
|
||||||
"\N{EM SPACE}3.14\N{EN SPACE}")
|
'3.14')
|
||||||
self.assertEqual(transform_decimal('123\u20ac'),
|
self.assertEqual(transform_decimal("\N{EM SPACE}3.14\N{EN SPACE}"),
|
||||||
'123\u20ac')
|
"\N{EM SPACE}3.14\N{EN SPACE}")
|
||||||
|
self.assertEqual(transform_decimal('123\u20ac'),
|
||||||
|
'123\u20ac')
|
||||||
|
|
||||||
@support.cpython_only
|
@support.cpython_only
|
||||||
def test_pep393_utf8_caching_bug(self):
|
def test_pep393_utf8_caching_bug(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue