Access fixtures in pytest_runtest_makereport/pytest_runtest_logreport
Hey,
while writing a simple plugin I was wondering if it is currently possible in pytest to access fixtures in the pytest_runtest_makereport and pytest_runtest_logreport hookwrappers.
I know I can achieve the desired effect with
@pytest.fixture
def something(request):
obj = SomeObject()
setattr(request.node, 'obj', obj)
@pytest.hookimp(hookwrapper=True)
def pytest_runtest_makereport(item, call):
outcome = yield
rep = outcome.get_result()
obj = getattr(item, 'obj')
But I was wondering if this functionality is already built in somehow and I didn't find it.
Thanks for your help!
it currently isnt, and its not yet clear how to add such support - to do so we need a clear idea on accessing setupstate
its by design impossible to do so in logreport
since this seems to be only a question i will close it as not actionable, should that call be wrong please make me aware
I just found out that there is item.funcargs which seems to be exactly what I need.
There was an example which used this functionality but the API reference doesn't mention this property. Maybe add this to the documentation as it's already builtin?
then we should certainly use a better name, and also note that it is potentially problematic for scoped things and indirect references