''' 对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()