Python 之测试数据驱动

Parameterized 模块

parameterized 第三方包的安装:

pip install parameterized

$ pip install parameterized
Collecting parameterized
  Downloading https://files.pythonhosted.org/packages/65/d4/b0b626eb263a4c2aa3ca3cd20ea3db410db837f7f6b5d3fc4a6c4bee3631/parameterized-0.6.1-py2.py3-none-any.whl
Installing collected packages: parameterized
Successfully installed parameterized-0.6.1
You are using pip version 18.0, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

用法介绍:

FYI: https://pypi.org/project/parameterized/

小demo:

#coding=UTF-8
#测试数据参数化模块
from parameterized import parameterized
import unittest

class Test(unittest.TestCase):
    # a list of tuples
    @parameterized.expand([
        ('li',124),
        ('mei',234),
        ('hong',345)
    ])
    def test_case1(self,name,password):
        name = name
        password = password
        print '{} login successful'.format(name)


if __name__ == '__main__':

    Test().run()

ddt

安装ddt

 pip install ddt

你可能感兴趣的:(python学习笔记)