pytest (三) fixture autouse参数使用
# autouse 默认是False
import pytest
@pytest.fixture(autouse=False)
def begin():
print('执行 begin')
# autouse是False,则需要在测试用例中加入参数begin
def test_a(begin):
print('执行 test_a')
# 结果如下
'''
执行 begin
执行 test_a
'''
import pytest
@pytest.fixture(autouse=True)
def begin():
print('执行 begin')
# autouse是Ture,则不需要在测试用例中加入参数begin
def test_a():
print('执行 test_a')
# 结果如下
'''
执行 begin
执行 test_a
'''

浙公网安备 33010602011771号