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

 

 

posted @ 2020-06-12 20:24  多测师_王sir  阅读(180)  评论(0编辑  收藏  举报