title: How to call a method on assert
body: <p>I am trying to capture as much information when an assert happens and before any clean-up code is called.
  Below is a simplified code of what most of our existing tests look like:</p>
  
  <p>In my conftest.py:</p>
  
  <pre><code>import pytest
  from datetime import datetime
  
  def pytest_runtest_makereport(item, call):
      print('%s: pytest_runtest_makereport(%s)' % (datetime.now(), call))
  
  def pytest_exception_interact(node, call, report):
      print('\n%s: pytest_exception_interact' % datetime.now())
  </code></pre>
  
  <p>In my test file:</p>
  
  <pre><code>import pytest
  from datetime import datetime
  
  @pytest.fixture(scope='function')
  def marshall_me():
      print('\n%s: starting test' % datetime.now())
      yield marshall_me
      print('\n%s: ending test' % datetime.now())
  
  class Device(object):
      def __enter__(self):
          print('\n%s: create object' % datetime.now())
          return self
  
      def __exit__(self, type, value, traceback):
          print('\n%s: clean-up object' % datetime.now())
  
  def test_fails(marshall_me):
      with Device():
          assert False
  </code></pre>
  
  <p>When I run this I get:</p>
  
  <pre><code>test_fails.py::test_fails  2017-04-26 17:07:37.447359: starting test
  2017-04-26 17:07:37.447453: pytest_runtest_makereport(&lt;CallInfowhen='setup' result: []&gt;) 
  2017-04-26 17:07:37.447583: create object
  2017-04-26 17:07:37.448397: clean-up object 
  2017-04-26 17:07:37.448614: pytest_runtest_makereport(&lt;CallInfowhen='call' exception: assert False&gt;) 
  FAILED 
  2017-04-26 17:07:37.462267: pytest_exception_interact 
  2017-04-26 17:07:37.462353: ending test
  2017-04-26 17:07:37.462428: pytest_runtest_makereport(&lt;CallInfo when='teardown' result: []&gt;)
  </code></pre>
  
  <p>I cannot use pytest_runtest_makereport and pytest_exception_interact because they get called after the clean-up function and that would then be too late for me to collect important information. Are there other similar functions that get called at the time that the assert is actually generated?</p>