1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# -*- coding:utf-8 -*-
from __future__ import unicode_literals
import unittest
from prettytable.prettytable import _char_block_width
def _width_test_factory(width, words):
def _(self):
map(lambda x: self.assertEqual(width, _char_block_width(ord(x))),
list(words))
return _
class CharBlockWidthTest(unittest.TestCase):
fixtures = {
'normal': (1, '12345qwerljk/.,WESD'),
'chs': (2, '石室诗士施氏嗜狮誓食十狮'),
'jp': (2, 'はじめまして'),
'hangul': (2, '우리글자언문청'),
'full_width_latin': (2, 'XYZ[\]^_xyz{|}~⦅'),
# 'cjk': (2, u''),
}
def test_fixtures(self):
for name in self.fixtures:
_width_test_factory(*self.fixtures[name])(self)
|