pytest 参数化

pytest参数化

pytest的参数化相当于unittest中的ddt
实现数据驱动,pytest.parametrize,数据驱动
pytest使用以下功能不能和unittest兼容:
1.当使用pytest的参数化paramatrize,不能做到和unittest兼容
2.当使用夹具fixture,(autouse=True可以),也不能和unittest兼容
3.钩子Custom_hooks

ddt模块不能和fixtrue共用,所以要换用pytest的参数化来实现ddt
参数化会和unittest冲突,因为setUp这些东西都不会去运行了,要改成pytest,不要继承unittest.TestCase
用法如下:
@pytest.mark.parametrize(“data”,Data…)

例如:
pytest 参数化
pytest 参数化
和ddt 的区别:
1.不需要用*
2.字符串作为第一个参数接收数据