是否可以在 setup_method 上使用 pytest.fixture 以便在每个测试用例之间始终完成某些操作?我尝试使用如下的夹具,结构看起来还可以。我能够在 funcA 完成之前执行每个测试用例。但是,我不想包含 ``` @pytest.mark.usefixtures('funcA')
class TestSuite(TestBase):
@classmethod
def setup_class(cls):
super(TestSuite, cls).setup_class()
'do something for setup class'
@classmethod
def teardown_class(cls):
super(TestSuite, cls).teardown_class()
'do something for teardown class'
def setup_method(self):
'do log in'
'do a,b c for setup_method'
@pytest.fixture(scope="function")
def funcA(self):
print('do function A')
@pytest.mark.usefixtures('funcA')
def test_caseA(self):
'check a'
@pytest.mark.usefixtures('funcA')
def test_caseB(self):
'check b'
@pytest.mark.usefixtures('funcA')
def test_caseC(self):
'check c'