Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit be66287

Browse files
committed
normalization is different between unicode builds, so use a new non-BMP char and add normalization test
1 parent f413b80 commit be66287

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

Lib/test/test_pep3131.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import unittest
2+
import sys
23
from test import support
34

45
class PEP3131Test(unittest.TestCase):
@@ -8,12 +9,20 @@ class T:
89
ä = 1
910
µ = 2 # this is a compatibility character
1011
= 3
11-
𝔘𝔫𝔦𝔠𝔬𝔡𝔢 = 4
12+
x󠄀 = 4
1213
self.assertEqual(getattr(T, "\xe4"), 1)
1314
self.assertEqual(getattr(T, "\u03bc"), 2)
1415
self.assertEqual(getattr(T, '\u87d2'), 3)
15-
v = getattr(T, "\U0001d518\U0001d52b\U0001d526\U0001d520\U0001d52c\U0001d521\U0001d522")
16-
self.assertEqual(v, 4)
16+
self.assertEqual(getattr(T, 'x\U000E0100'), 4)
17+
18+
def test_non_bmp_normalized(self):
19+
𝔘𝔫𝔦𝔠𝔬𝔡𝔢 = 1
20+
# On wide builds, this is normalized, but on narrow ones it is not. See
21+
# #12746.
22+
try:
23+
self.assertIn("𝔘𝔫𝔦𝔠𝔬𝔡𝔢", dir())
24+
except AssertionError:
25+
raise unittest.case._ExpectedFailure(sys.exc_info())
1726

1827
def test_invalid(self):
1928
try:

0 commit comments

Comments
 (0)