|
|
|
'''
|
|
|
|
对analysisEmotion中的函数进行测试python -m unittest
|
|
|
|
其中对于文件读取、模型加载和图表绘制一类的函数没有进行测试
|
|
|
|
代码覆盖率测试coverage run -m unittest discover
|
|
|
|
'''
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
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()
|