テスト ケース モジュールとテスト スイート モジュールを使用できるように、テスト スーツを 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 も機能しません...