Skip to content

Commit

Permalink
add generator test
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudaice committed May 11, 2013
1 parent 0c050b5 commit 9ee20a5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/jieba_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#-*-coding: utf-8 -*-
import sys
sys.path.append("../")
import jieba
import unittest
import types
import jieba
jieba.initialize()


Expand Down Expand Up @@ -103,13 +104,15 @@ def tearDown(self):
def testDefaultCut(self):
for content in test_contents:
result = jieba.cut(content)
assert isinstance(result, types.GeneratorType), "Test DefaultCut Generator error"
result = list(result)
assert isinstance(result, list), "Test DefaultCut error on content: %s" % content
print >> sys.stderr, " , ".join(result)

def testCutAll(self):
for content in test_contents:
result = jieba.cut(content, cut_all=True)
assert isinstance(result, types.GeneratorType), "Test CutAll Generator error"
result = list(result)
assert isinstance(result, list), "Test CutAll error on content: %s" % content
print >> sys.stderr, " , ".join(result)
Expand All @@ -118,13 +121,15 @@ def testSetDictionary(self):
jieba.set_dictionary("foobar.txt")
for content in test_contents:
result = jieba.cut(content)
assert isinstance(result, types.GeneratorType), "Test SetDictionary Generator error"
result = list(result)
assert isinstance(result, list), "Test SetDictionary error on content: %s" % content
print >> sys.stderr, " , ".join(result)

def testCutForSearch(self):
for content in test_contents:
result = jieba.cut_for_search(content)
assert isinstance(result, types.GeneratorType), "Test CutForSearch Generator error"
result = list(result)
assert isinstance(result, list), "Test CutForSearch error on content: %s" % content
print >> sys.stderr, " , ".join(result)
Expand All @@ -133,6 +138,7 @@ def testPosseg(self):
import jieba.posseg as pseg
for content in test_contents:
result = pseg.cut(content)
assert isinstance(result, types.GeneratorType), "Test Posseg Generator error"
result = list(result)
assert isinstance(result, list), "Test Posseg error on content: %s" % content
print >> sys.stderr, " , ".join([w.word + " / " + w.flag for w in result])
Expand Down

0 comments on commit 9ee20a5

Please sign in to comment.