我有一个实现以下钩子的插件:
def pytest_runtest_setup(item):
item.config.bla = Bla()
def pytest_runtest_teardown(item):
item.config.bla.do_bla()
item.config.bla = None
一切正常,直到一些测试开始抛出AttributeError: 'NoneType' object has no attribute 'do_bla'
,事实上,item.config.bla
是None
这发生在我标记为的测试中
@pytest.mark.skip(reason='bla bla')
def test_bla():
pass
我尝试ipdb
了设置挂钩 - 但它没有被调用,而拆解是。在拆解时不调用设置进行跳过测试是否有意义?
我可以用我的拆解包装,try, except
但我想验证根本原因......