parent
da84c99f77
commit
43845279fe
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,27 @@
|
||||
'''
|
||||
对analysisEmotion中的函数进行测试python -m unittest
|
||||
其中对于文件读取、模型加载和图表绘制一类的函数没有进行测试
|
||||
'''
|
||||
|
||||
import unittest
|
||||
import barrage.analysisEmotion as ba
|
||||
|
||||
class TestEmotion(unittest.TestCase):
|
||||
count = [9, 100, 300, 152, 789, 666, 552, 310, 218, 20]
|
||||
pro = [0.119, 0.340, 0.281, 0.988, 0.284, 0.331, 0.210, 0.956, 0.100, 0.673]
|
||||
probability = [0.648, 0.302, 0.996, 0.289, 0.462, 0.331, 0.248, 0.210, 0.008, 0.127]
|
||||
result = [0.5951, 0.30237623762376237, 0.993624584717608, 0.2935686274509804, 0.46177468354430384, 0.331, 0.24793128390596744, 0.21239871382636655, 0.008420091324200914, 0.153]
|
||||
|
||||
def setUp(self):
|
||||
print('start')
|
||||
|
||||
def test_emoChange(self):
|
||||
for i in range(10):
|
||||
compu = self.probability[i] + (self.pro[i] - self.probability[i])/(self.count[i]+1)
|
||||
self.assertTrue(compu, self.result[i])
|
||||
|
||||
def tearDown(self):
|
||||
print('end')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,50 @@
|
||||
'''
|
||||
对handleData中的函数进行测试python -m unittest
|
||||
其中对于文件读取一类的函数没有进行测试
|
||||
'''
|
||||
|
||||
import unittest
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import barrage.handleData as bh
|
||||
|
||||
class TestData(unittest.TestCase):
|
||||
origin_list = [
|
||||
'123',
|
||||
'666',
|
||||
'999',
|
||||
'ai',
|
||||
'555',
|
||||
'abc',
|
||||
'你我他',
|
||||
]
|
||||
keyWord_list = [
|
||||
['1'],
|
||||
['6'],
|
||||
['9'],
|
||||
['ai'],
|
||||
['5'],
|
||||
['2'],
|
||||
['3'],
|
||||
['我'],
|
||||
['ab'],
|
||||
['i']
|
||||
]
|
||||
|
||||
def setUp(self):
|
||||
print('start')
|
||||
|
||||
def test_ChangeDfToString(self):
|
||||
for _ in range(10):
|
||||
df=pd.DataFrame(np.random.randn(4,4),index=list('ABCD'),columns=list('ABCD'))
|
||||
self.assertTrue(type(bh.ChangeDfToString(df)) == str)
|
||||
|
||||
def test_GetKeyFromList(self):
|
||||
for i in range(10):
|
||||
self.assertTrue(type(bh.GetKeyFromList(self.keyWord_list[i], self.origin_list)) == list)
|
||||
|
||||
def tearDown(self):
|
||||
print('end')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,34 @@
|
||||
'''
|
||||
对wordCloud中的函数进行测试python -m unittest
|
||||
对于其中文件读取和绘制图片一类的函数没有进行测试
|
||||
'''
|
||||
|
||||
import unittest
|
||||
import barrage.wordCloud as bw
|
||||
|
||||
class TestWordCloud(unittest.TestCase):
|
||||
word_list = [
|
||||
'盖 闻 天地 之 数 有 十二万 九千 六百 岁 为 一元',
|
||||
'将 一元 分为 十二 会 乃 子 丑 寅 卯 辰 巳 午 未 申 酉 戌 亥 之 十二支 也',
|
||||
'每 会 该 一万 八百岁',
|
||||
'天气 下降 地气 上升 天地 交合 群物 皆 生',
|
||||
'那座 山 正当 顶上 有 一块 仙石',
|
||||
'其 石 有 三丈 六尺 五寸 高 有 二丈 四尺 围圆 三丈 六尺 五寸 高 按 周天 三百六十五度 二丈 四尺 围圆 按 政历 二十四气',
|
||||
'盖 自 开辟 以来 每 受 天真 地 秀 日精 月华 感 之 既久 遂有 灵通 之 意',
|
||||
'内 育 仙胞 一日 迸裂 产 一 石 卵',
|
||||
'因 见风 化作 一个 石猴 五官 俱备 四肢 皆全 便就 学 爬 学 走 拜了 四方',
|
||||
'目 运 两道 金光 射 冲 斗府'
|
||||
]
|
||||
|
||||
def setUp(self):
|
||||
print('start')
|
||||
|
||||
def test_ChangeDfToString(self):
|
||||
for i in range(10):
|
||||
self.assertTrue(type(bw.ChangeToFreq(self.word_list[i])) == dict)
|
||||
|
||||
def tearDown(self):
|
||||
print('end')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Loading…
Reference in new issue