title: Detect whether test has failed within fixture
body: <p>I am debugging an intermittent test failure. For this purposes I want to dump a lot of debug information if a test failed. Dumping debug stuff is quite slow process which produces a lot of data, so I do not want to do this for every test.</p>
  
  <p>I am using pytest and yield autouse fixture should work great</p>
  
  <pre><code>@pytest.yield_fixture(scope="function", autouse=True)
  def dump_on_failue(request):
      prepare_debug_dump()
  
      yield
  
      if test_failed(request):
          debug_dump()
  </code></pre>
  
  <p>The problem is that I can't figure out how do I detect whether test has failed or not. There was <a href="https://stackoverflow.com/questions/13364868/in-pytest-how-can-i-figure-out-if-a-test-failed-from-request">a questions already</a> and even note <a href="http://pytest.org/dev/example/simple.html#making-test-result-information-available-in-fixtures" rel="noreferrer">on pytest website</a>:</p>
  
  <pre><code>    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)
  </code></pre>
  
  <p>Unfortunately this code does not work anymore. There are no rep_setup and rep_calls symbols in node object. I tried to dig request and node object, but no luck.</p>
  
  <p>Anybody knows how to detect whether test failed?</p>