说我有一个夹具,我想在大多数测试中分享:
@pytest.fixture(scope='session')
def account():
# create a new account
但是现在在其中一个测试中,我想覆盖scope='session'
位并实际让夹具重新执行(创建一个新帐户)。有没有办法告诉灯具只是为了一次测试“覆盖缓存/记忆”?
答案 0 :(得分:0)
如果不试图找出问题的答案,我认为您的问题可以更轻松地解决。只需将帐户创建分解为另一个功能并编写两个灯具:
def create_account():
return 'account'
@pytest.fixture(scope='session')
def account():
return create_account()
@pytest.fixture(scope='something else'):
def another_account():
return create_account()
答案 1 :(得分:0)
只需从测试中手动调用夹具将使其重新执行。 e.g。
setContentView(BIND_AUTO_CREATE);