我可以将测试套件实现为 python 类/模块,以便我拥有测试用例模块和测试套件模块。我也想将测试套件中的参数传递给测试用例。
像这样的东西:
测试套件模块:
import unittest class GPUScoringMatrixTestSuite(unittest.TestSuite): def suite(): suite = unittest.TestSuite() suite.addTest(GPUScoringMatrixTestCase('PAM_350.txt')) suite.addTest(GPUScoringMatrixTestCase('PAM_250.txt')) self.run(suite)
测试用例模块:
class GPUScoringMatrixTestCase(unittest.TestCase): def __init__(self, matrix_file): self.filename = matrix_file @classmethod def setUpClass(self): self.matrix = GPUScoringMatrix(self.filename) def test_sum_penalties(self): sum = 0 for i in self.matrix.penalties: sum += i self.assertEqual(sum, -970, 'Iconsistence penalties between scoring matrices')
参数 matrix_file 也不起作用......