title: How to pass test status to it's teardown, through a fixture preferably
body: <p>I have a BaseTest class which has tear_down and I want to have inside tear_down a variable representing wether or not the test has failed.</p>
  <p>I tried look at A LOT of older posts but I coulden't implement them as they were hooks or mixture of hook and fixture and something did not work on my end.</p>
  <p>What is the best practice for doing that?</p>
  <p>Last thing I've tried was -</p>
  <pre><code>@pytest.hookimpl(tryfirst=True, hookwrapper=True)
  def pytest_runtest_makereport(item):
      outcome = yield
      rep = outcome.get_result()
  
      # set a report attribute for each phase of a call, which can
      # be &quot;setup&quot;, &quot;call&quot;, &quot;teardown&quot;
  
      setattr(item, &quot;rep_&quot; + rep.when, rep)
  </code></pre>
  <p>Then pass request fixture to teardown and inside use</p>
  <pre><code>has_failed = request.node.rep_call.failed 
  </code></pre>
  <p>But request had no attributes at all, it was a method.
  Also tried -</p>
  <pre><code>@pytest.fixture
  def has_failed(request):
      yield
  
      return True if request.node.rep_call.failed else False
  </code></pre>
  <p>and pass it like that.</p>
  <pre><code>def teardown_method(self, has_failed):
  </code></pre>
  <p>And again, no attributes.</p>
  <p>Isn't there a simple fixture to just do like request.test_status or something like that?</p>
  <p>It's important that the teardown will have that bool parameter wether or not it failed and not do stuff outside the teardown.</p>
  <p>Thanks!</p>