(self)
| 5 | |
| 6 | class 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', '!', '_']: |
nothing calls this directly
no test coverage detected