标签:nbsp list print down src http 技术 pip install
一、环境准备
1.安装ddt模块,打开cmd输入pip install ddt在线安装
二、数据驱动原理
1.测试数据为多个字典的list类型
2.测试类前加修饰@ddt.ddt
3.case前加修饰@ddt.data()
4.运行后用例会自动加载成三个单独的用例
# coding:utf-8 import ddt import unittest # 测试数据 test_data = [{"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_data) def test_ddt1(self, data): print(data) @ddt.data(*test_data2) def test_ddt2(self, data): print(data) if __name__ == "__main__": unittest.main()
标签:nbsp list print down src http 技术 pip install
原文地址:http://www.cnblogs.com/lingzeng86/p/6790827.html