unittest使用ddt来实现测试用例参数化、或parameterized实现测试用例参数化,pytest测试用例里面对应的参数可以用 parametrize 实现参数化,今天我们来了解下fixture参数化params
fixture的参数可以解决大量重复代码工作,比如数据库的连接、查询、关闭等.同样可以使用参数化来测试多条数据用例。
fixture源码:
传入参数scope,params,autouse,ids,name
def fixture(scope="function", params=None, autouse=False, ids=None, name=None):
"""Decorator to mark a fixture factory function.
This decorator can be used, with or without parameters, to define a
fixture function.
The name of the fixture function