title: In pytest, how can I figure out if a test failed? (from "request")
body: <p>I'm using Selenium with PYTEST to test a site. I would like to take a screenshot of the page whenever a test fails (and only when it fails). </p>
  
  <p>Is there a way that I can do this? The docs are quiet when it comes to this (or I can't find it). I would assume that it would be something like </p>
  
  <pre><code>request.function.failed
  </code></pre>
  
  <p>and it would return a boolean or something. </p>
  
  <p>This is what I wanted to do:</p>
  
  <pre><code>@pytest.fixture()
  def something(request):
      if request.function.failed:
          print "I failed"
  </code></pre>
  
  <p>This would be added to a finalizer, of course. Can it be done? Using pytest 2.3.3</p>
  
  <p>Thanks.</p>