I have a plugin that implements the following hooks:
def pytest_runtest_setup(item):
item.config.bla = Bla()
def pytest_runtest_teardown(item):
item.config.bla.do_bla()
item.config.bla = None
All works fine until some tests start to throw AttributeError: 'NoneType' object has no attribute 'do_bla'
and indeed, item.config.bla
is None
This happens in tests which I marked as
@pytest.mark.skip(reason='bla bla')
def test_bla():
pass
I tried ipdb
-ing the setup hook - but it is not called, while the teardown is. Does it make sense that setups are not called for skip tests while teardowns are?
I can wrap my teardown with try, except
but I want to verify the root cause...