MCPcopy Index your code
hub / github.com/python/cpython / run_name_tests

Method run_name_tests

Lib/test/test_unicodedata.py:710–740  ·  view source on GitHub ↗
(self, testdata)

Source from the content-addressed store, hash-verified

708 self.run_name_tests(testdata)
709
710 def run_name_tests(self, testdata):
711 names_ref = {}
712
713 def parse_cp(s):
714 return int(s, 16)
715
716 # Parse data
717 for line in testdata:
718 line = line.strip()
719 if not line or line.startswith("#"):
720 continue
721 raw_cp, name = line.split("; ")
722 # Check for a range
723 if ".." in raw_cp:
724 cp1, cp2 = map(parse_cp, raw_cp.split(".."))
725 # remove ‘*’ at the end
726 assert name[-1] == '*', (raw_cp, name)
727 name = name[:-1]
728 for cp in range(cp1, cp2 + 1):
729 names_ref[cp] = f"{name}{cp:04X}"
730 elif name[-1] == '*':
731 cp = parse_cp(raw_cp)
732 name = name[:-1]
733 names_ref[cp] = f"{name}{cp:04X}"
734 else:
735 assert '*' not in name, (raw_cp, name)
736 cp = parse_cp(raw_cp)
737 names_ref[cp] = name
738
739 for cp in range(0, sys.maxunicode + 1):
740 self.assertEqual(self.db.name(chr(cp), None), names_ref.get(cp))
741
742 def test_isxidstart(self):
743 self.assertTrue(self.db.isxidstart('S'))

Callers 1

test_all_namesMethod · 0.95

Calls 6

stripMethod · 0.45
startswithMethod · 0.45
splitMethod · 0.45
assertEqualMethod · 0.45
nameMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected