ddt数据驱动最简单的应用一【多测师】
import ddt import unittest @ddt.ddt class Test(unittest.TestCase): test_data = [(1, 2, 3), (3, 4, 5)] @classmethod def setUpClass(cls): pass @classmethod def tearDownClass(cls): pass @ddt.unpack @ddt.data(*test_data) def test_run(self, x, y, z): print(x, y, z) if __name__ == '__main__': unittest.main()
运行结果:
(1, 2, 3)
(3, 4, 5)
..
----------------------------------------------------------------------
Ran 2 tests in 0.000s
OK