title: How to detect when pytest test case failed?
body: <p>I am using pytest with selenium to automate a website. I want to take some screen shot only when a test case fails. I have previosly used TestNG and with TestNG it's quite east using the ITestListner.
  Do we have something like that in pytest.</p>
  
  <p>I have tried to achieve this using the teardown_method()
  But this method is not getting executed when a test case fails.</p>
  
  <pre><code>import sys
  
  from unittestzero import Assert
  class TestPY:
      def setup_method(self, method):
          print("in setup method")
          print("executing " + method.__name__)
  
      def teardown_method(self, method):
          print(".....teardown")
          if sys.exc_info()[0]:
              test_method_name = method
              print test_method_name
  
      def test_failtest(self):
          Assert.fail("failed test")
  </code></pre>
  
  <p><code>teardown_method()</code> get executed only when there are no fails</p>