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

Method test_str_width

Lib/test/test_pyrepl/test_utils.py:7–33  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5
6class TestUtils(TestCase):
7 def test_str_width(self):
8 characters = [
9 'a',
10 '1',
11 '_',
12 '!',
13 '\x1a',
14 '\u263A',
15 '\uffb9',
16 '\N{LATIN SMALL LETTER E WITH ACUTE}', # é
17 '\N{LATIN SMALL LETTER E WITH CEDILLA}', # ȩ
18 '\u00ad',
19 ]
20 for c in characters:
21 self.assertEqual(str_width(c), 1)
22
23 zero_width_characters = [
24 '\N{COMBINING ACUTE ACCENT}',
25 '\N{ZERO WIDTH JOINER}',
26 ]
27 for c in zero_width_characters:
28 with self.subTest(character=c):
29 self.assertEqual(str_width(c), 0)
30
31 characters = [chr(99989), chr(99999)]
32 for c in characters:
33 self.assertEqual(str_width(c), 2)
34
35 def test_wlen(self):
36 for c in ['a', 'b', '1', '!', '_']:

Callers

nothing calls this directly

Calls 3

str_widthFunction · 0.90
assertEqualMethod · 0.45
subTestMethod · 0.45

Tested by

no test coverage detected