pytest-fixture参数化
fixture参数化
指定params属性,实现fixture的参数化,引用该fixture的测试方法将遍历全部参数
import pytest
@pytest.fixture(params=["unittest", "pytest"])
def fix1(request):
print(request.param)
def test_main(fix1):
assert 0
if __name__ == "__main__":
pytest.main(["-v"])
===============================
____ test_main[unittest] ______
unittest
____ test_main[pytest] ______
pytest