From 77d7d1b0fcbb1c6066c92e15d8f1302f896e4b73 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 19:11:18 +0000 Subject: [PATCH] feat: Refactor tests/test_jieba.py to be more modu --- tests/test_jieba.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/test_jieba.py diff --git a/tests/test_jieba.py b/tests/test_jieba.py new file mode 100644 index 00000000..7f2b7421 --- /dev/null +++ b/tests/test_jieba.py @@ -0,0 +1,23 @@ +import unittest + +import jieba + + +class TestJieba(unittest.TestCase): + def setUp(self): + self.text = "This is a test text for jieba" + + def test_cut(self): + result = jieba.cut(self.text) + self.assertEqual(list(result), ['This', ' ', 'is', ' ', 'a', ' ', 'test', ' ', 'text', ' ', 'for', ' ', 'jieba']) + + def test_cut_all(self): + result = jieba.cut(self.text, cut_all=True) + self.assertEqual(list(result), ['This', ' ', 'is', ' ', 'a', ' ', 'test', ' ', 'text', ' ', 'for', ' ', 'jieba']) + + def test_cut_for_search(self): + result = jieba.cut_for_search(self.text) + self.assertEqual(list(result), ['This', ' ', 'is', ' ', 'a', ' ', 'test', ' ', 'text', ' ', 'for', ' ', 'jieba']) + +if __name__ == '__main__': + unittest.main()