You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.1 KiB
51 lines
1.1 KiB
'''
|
|
对handleData中的函数进行测试python -m unittest
|
|
其中对于文件读取一类的函数没有进行测试
|
|
代码覆盖率测试coverage run -m unittest discover
|
|
'''
|
|
|
|
import unittest
|
|
import numpy as np
|
|
import pandas as pd
|
|
from barrage import 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() |