From d4161374194a5ad8a4ad7eeb88fb21e1b0fd96b8 Mon Sep 17 00:00:00 2001 From: Batuhan Taskaya Date: Wed, 21 Sep 2022 14:52:40 +0200 Subject: [PATCH] [3.10] gh-96954: Add tests for unicodedata.name/lookup (GH-96955) They were undertested, and since GH-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 (cherry picked from commit 5a32eeced2c537c13613dd4ff5b2767a37037294) Co-authored-by: Batuhan Taskaya --- Lib/test/test_unicodedata.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py index 213b3cf2529986..2a93f0fabe2108 100644 --- a/Lib/test/test_unicodedata.py +++ b/Lib/test/test_unicodedata.py @@ -95,6 +95,13 @@ def test_function_checksum(self): 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)