15. Python DDT数据驱动

什么是DDT
ddt是Python的第三方库。ddt模块提供了创建数据驱动的测试。

安装DDT:

PS D:\Python\Scripts> D:\Python\Scripts\pip.exe install ddt
Collecting ddt
  Downloading https://files.pythonhosted.org/packages/cf/f5/f83dea32dc3fb3be1e5afab8438dce73ed587740a2a061ae2ea56e04a36d/ddt-1.2.1-py2.py3-none-any.whl
Installing collected packages: ddt
Successfully installed ddt-1.2.1
PS D:\Python\Scripts>

新建待测类:

__author__ = 'Hello'
class PrintMsg:
    def fun_1(self,a):
        print("获取的参数是%s"%a)

    def fun_2(self,a,b):
        print("获取的第A个参数是%s"%a)
        print("获取的第B个参数是%s"%b)

    def fun_3(self,a,b,c):
        print("获取的第A个参数是%s"%a)
        print("获取的第B个参数是%s"%b)
        print("获取的第C个参数是%s"%c)

写一个测试类:

__author__ = 'Hello'
import unittest
from class_ddt.print_msg import PrintMsg

class TestPrintMsg(unittes
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值