1.安装ddt包

  pip install ddt

2.引入包 

import unittest
from ddt import ddt, data, unpack
@ddt
class MyTestCase(unittest.TestCase):

    # 用元组存放数据,一个参数
    @data(1,-3,'co','')
    def testcase01(self, value):
        print(value)
        self.assertEqual(1, value)

    # 用元组存放数据,多个参数
    @data((1,2),(2,4))
    @unpack
    def testcase02(self, value1, value2):
        print(value1, value2)
        self.assertEqual(value1,value2-1)

if __name__ == '__main__':
    unittest.main()