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.字符串作为第一个参数接收数据

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-15
  • 2021-05-28
  • 2021-11-03
猜你喜欢
  • 2021-11-16
  • 2022-12-23
  • 2022-02-17
  • 2021-12-18
相关资源
相似解决方案