ddt
Posted bobo200
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ddt相关的知识,希望对你有一定的参考价值。
# coding:utf-8
import ddt
import unittest
# 测试数据
test_data1 = [{"username": "zhangsan", "pwd": "zhangsan"},
{"username": "lisi", "pwd": "lisi"},
{"username": "wangwu", "pwd": "wangwu"},
]
test_data2 = [{"username": "wukong", "pwd": "wukong"},
{"username": "wuneng", "pwd": "woneng"},
{"username": "wujing", "pwd": "wujing"},
]
@ddt.ddt
class Test(unittest.TestCase):
def setUp(self):
print("Start!")
def tearDown(self):
print("end!")
@ddt.data(*test_data1)
def test_ddt1(self, data):
print(data)
@ddt.data(*test_data2)
def test_ddt2(self, data):
print(data)
if __name__ == "__main__":
unittest.main()
以上是关于ddt的主要内容,如果未能解决你的问题,请参考以下文章