diff options
author | kxxoling <kxxoling@gmail.com> | 2015-06-12 17:35:19 +0800 |
---|---|---|
committer | kxxoling <kxxoling@gmail.com> | 2015-06-14 18:45:26 +0800 |
commit | d1b50cfb7db88183953f7397c62aca1a6fe72348 (patch) | |
tree | 391c916040484e795c9a243437b79c746d4499dc | |
parent | 2e22c02ece9c6d9405d5370c9977a34a297e0544 (diff) | |
download | python-prettytable-ptable-d1b50cfb7db88183953f7397c62aca1a6fe72348.tar.gz |
Add multi type of char blocks width test
-rw-r--r-- | tests/__init__.py | 0 | ||||
-rw-r--r-- | tests/test_utils.py | 29 |
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/__init__.py diff --git a/tests/test_utils.py b/tests/test_utils.py new file mode 100644 index 0000000..6ed710b --- /dev/null +++ b/tests/test_utils.py @@ -0,0 +1,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) + |