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

Method run_grapheme_break_tests

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

Source from the content-addressed store, hash-verified

1310 self.run_grapheme_break_tests(testdata)
1311
1312 def run_grapheme_break_tests(self, testdata):
1313 for line in testdata:
1314 line, _, comment = line.partition('#')
1315 line = line.strip()
1316 if not line:
1317 continue
1318 comment = comment.strip()
1319
1320 chunks = []
1321 breaks = []
1322 pos = 0
1323 for field in line.replace('×', ' ').split():
1324 if field == '÷':
1325 chunks.append('')
1326 breaks.append(pos)
1327 else:
1328 chunks[-1] += chr(int(field, 16))
1329 pos += 1
1330 self.assertEqual(chunks.pop(), '', line)
1331 input = ''.join(chunks)
1332 with self.subTest(line):
1333 result = list(unicodedata.iter_graphemes(input))
1334 self.assertEqual(list(map(str, result)), chunks, comment)
1335 self.assertEqual([x.start for x in result], breaks[:-1], comment)
1336 self.assertEqual([x.end for x in result], breaks[1:], comment)
1337 for i in range(1, len(breaks) - 1):
1338 result = list(unicodedata.iter_graphemes(input, breaks[i]))
1339 self.assertEqual(list(map(str, result)), chunks[i:], comment)
1340 self.assertEqual([x.start for x in result], breaks[i:-1], comment)
1341 self.assertEqual([x.end for x in result], breaks[i+1:], comment)
1342
1343 def test_reference_loops(self):
1344 # Test that reference loops involving GraphemeBreakIterator or

Callers 1

test_grapheme_breakMethod · 0.95

Calls 10

listClass · 0.85
partitionMethod · 0.45
stripMethod · 0.45
splitMethod · 0.45
replaceMethod · 0.45
appendMethod · 0.45
assertEqualMethod · 0.45
popMethod · 0.45
joinMethod · 0.45
subTestMethod · 0.45

Tested by

no test coverage detected