I found that another fixture could be used to wrap the test function:
@pytest.fixture
def a():
return A()
@pytest.fixture(scope='function')
def wrapper(a):
a.setup()
yield
a.teardown()
def test_a(wrapper):
logger.info('test_a')
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…