]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-96954: Add tests for unicodedata.name/lookup (#96955)
authorBatuhan Taskaya <isidentical@gmail.com>
Wed, 21 Sep 2022 12:52:40 +0000 (14:52 +0200)
committerGitHub <noreply@github.com>
Wed, 21 Sep 2022 12:52:40 +0000 (14:52 +0200)
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 <cfbolz@gmx.de>
Lib/test/test_unicodedata.py

index 0c31d80e103dbf1d2e914cadc131d28f1ee1c3a8..a85bda3144bc35f55f38986a16732feb53409c2a 100644 (file)
@@ -71,7 +71,7 @@ class UnicodeFunctionsTest(UnicodeDatabaseTest):
 
     # Update this if the database changes. Make sure to do a full rebuild
     # (e.g. 'make distclean && make') to get the correct checksum.
-    expectedchecksum = '84b88a89f40aeae96852732f9dc0ee08be49780f'
+    expectedchecksum = '26ff0d31c14194b4606a5b3a81ac36df3a14e331'
 
     @requires_resource('cpu')
     def test_function_checksum(self):
@@ -91,11 +91,19 @@ class UnicodeFunctionsTest(UnicodeDatabaseTest):
                 str(self.db.mirrored(char)),
                 str(self.db.combining(char)),
                 unicodedata.east_asian_width(char),
+                self.db.name(char, ""),
             ]
             h.update(''.join(data).encode("ascii"))
         result = h.hexdigest()
         self.assertEqual(result, self.expectedchecksum)
 
+    @requires_resource('cpu')
+    def test_name_inverse_lookup(self):
+        for i in range(sys.maxunicode + 1):
+            char = chr(i)
+            if looked_name := self.db.name(char, None):
+                self.assertEqual(self.db.lookup(looked_name), char)
+
     def test_digit(self):
         self.assertEqual(self.db.digit('A', None), None)
         self.assertEqual(self.db.digit('9'), 9)