-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Refactor tests/test_jieba.py to be more modu
- Loading branch information
1 parent
77f7764
commit 77d7d1b
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |