I am debugging an intermittent test. To do this, I want to reset a lot of debugging information if the test fails. Fail-safe debugging material is a rather slow process that yields a lot of data, so I donβt want to do this for every test.
I am using pytest and autouse fixture output should work fine
@pytest.yield_fixture(scope="function", autouse=True) def dump_on_failue(request): prepare_debug_dump() yield if test_failed(request): debug_dump()
The problem is that I cannot figure out how to determine if the test completed or not. There was already a question and even a note on the pytest website :
if request.node.rep_setup.failed: print ("setting up a test failed!", request.node.nodeid) elif request.node.rep_setup.passed: if request.node.rep_call.failed: print ("executing test failed", request.node.nodeid)
Unfortunately, this code no longer works. There are no rep_setup and rep_calls characters in the node object. I tried to query the request and the node object, but no luck.
Does anyone know how to determine if a test passed?
source share