Skip to content

Commit 07715bf

Browse files
committed
Add tests for _pyrepr.utils
1 parent a8dc6d6 commit 07715bf

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Lib/test/test_pyrepl/test_utils.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from unittest import TestCase
2+
3+
from _pyrepl.utils import str_width, wlen
4+
5+
6+
class TestUtils(TestCase):
7+
def test_str_width(self):
8+
characters = ['a', '1', '_', '!', '\x1a', '\u263A', '\uffb9']
9+
for c in characters:
10+
self.assertEqual(str_width(c), 1)
11+
12+
characters = [chr(99989), chr(99999)]
13+
for c in characters:
14+
self.assertEqual(str_width(c), 2)
15+
16+
def test_wlen(self):
17+
for c in ['a', 'b', '1', '!', '_']:
18+
self.assertEqual(wlen(c), 1)
19+
self.assertEqual(wlen('\x1a'), 2)
20+
21+
self.assertEqual(wlen('hello'), 5)
22+
self.assertEqual(wlen('hello'+'\x1a'), 7)
23+
self.assertEqual(wlen('hello'+'\0x1B'), 9)

0 commit comments

Comments
 (0)