aboutsummaryrefslogtreecommitdiffstats
path: root/97suifangqa/apps/utils/xpinyin/tests.py
diff options
context:
space:
mode:
Diffstat (limited to '97suifangqa/apps/utils/xpinyin/tests.py')
-rw-r--r--97suifangqa/apps/utils/xpinyin/tests.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/97suifangqa/apps/utils/xpinyin/tests.py b/97suifangqa/apps/utils/xpinyin/tests.py
new file mode 100644
index 0000000..7ec25d7
--- /dev/null
+++ b/97suifangqa/apps/utils/xpinyin/tests.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+import unittest
+
+
+class PinyinTests(unittest.TestCase):
+
+ def Pinyin(self, *a, **kw):
+ from xpinyin import Pinyin
+ return Pinyin(*a, **kw)
+
+ def setUp(self):
+ self.p = self.Pinyin()
+
+ def test_get_pinyin_with_default_splitter(self):
+ self.assertEqual(self.p.get_pinyin(u'上海'), u'shang-hai')
+
+ def test_get_pinyin_with_splitter(self):
+ self.assertEqual(self.p.get_pinyin(u'上海', splitter=u''), u'shanghai')
+
+ def test_get_pinyin_mixed_words(self):
+ self.assertEqual(self.p.get_pinyin(u'Apple发布iOS7'), u'Apple-fa-bu-iOS7')
+
+ def test_get_initials(self):
+ self.assertEqual(self.p.get_initials(u'你'), u'N')