Skip to content

Commit 5a32eec

Browse files
isidenticalcfbolz
andauthored
gh-96954: Add tests for unicodedata.name/lookup (#96955)
They were undertested, and since #96954 might involve a rewrite of this part of the code we want to ensure that there won't be any behavioral change. Co-authored-by: Carl Friedrich Bolz-Tereick <[email protected]>
1 parent e5ab0b6 commit 5a32eec

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Lib/test/test_unicodedata.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class UnicodeFunctionsTest(UnicodeDatabaseTest):
7171

7272
# Update this if the database changes. Make sure to do a full rebuild
7373
# (e.g. 'make distclean && make') to get the correct checksum.
74-
expectedchecksum = '84b88a89f40aeae96852732f9dc0ee08be49780f'
74+
expectedchecksum = '26ff0d31c14194b4606a5b3a81ac36df3a14e331'
7575

7676
@requires_resource('cpu')
7777
def test_function_checksum(self):
@@ -91,11 +91,19 @@ def test_function_checksum(self):
9191
str(self.db.mirrored(char)),
9292
str(self.db.combining(char)),
9393
unicodedata.east_asian_width(char),
94+
self.db.name(char, ""),
9495
]
9596
h.update(''.join(data).encode("ascii"))
9697
result = h.hexdigest()
9798
self.assertEqual(result, self.expectedchecksum)
9899

100+
@requires_resource('cpu')
101+
def test_name_inverse_lookup(self):
102+
for i in range(sys.maxunicode + 1):
103+
char = chr(i)
104+
if looked_name := self.db.name(char, None):
105+
self.assertEqual(self.db.lookup(looked_name), char)
106+
99107
def test_digit(self):
100108
self.assertEqual(self.db.digit('A', None), None)
101109
self.assertEqual(self.db.digit('9'), 9)

0 commit comments

Comments
 (0)