title: unable to capture results of pytest in decorator
body: <p>my decorator for pytest tests exits the decorator as soon as the function is called. Works great if I run the file with python instead of pytest.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>def dec(func):
      def wrapper(*args, **kwargs):
          print('do some stuff')
          result = func(*args, **kwargs)
          print('ran function')
          return False if result else return True
      return wrapper
  
  @dec
  def test_something_is_not_true():
      return False # assert False
  
  @dec
  def test_something_is_true():
      return True # assert True
  
  
  print(test_something_is_not_true())
  print(test_something_is_true())
  </code></pre>
  
  <p>the results of this when I run the file with python are as follows:</p>
  
  <pre><code>C:\tests&gt; python test.py
  do some stuff
  ran function
  True
  do some stuff
  ran function
  False
  </code></pre>
  
  <p>works great!</p>
  
  <p>but when I run it with pytest it stops at the <code>result = func(*args, **kwargs)</code> line and never executes the <code>print('ran function')</code> line:</p>
  
  <pre><code>C:\tests&gt;pytest test.py
  ============================= test session starts =============================
  platform win32 -- Python 3.6.4, pytest-3.3.2, py-1.5.2, pluggy-0.6.0
  rootdir: C:\, inifile:
  plugins: metadata-1.7.0, jira-0.3.6, html-1.19.0
  collected 2 items
  
  test.py F.                                                               [100%]
  
  ================================== FAILURES ===================================
  _________________________ test_something_is_not_true __________________________
  
  args = (), kwargs = {}
  
      def wrapper(*args, **kwargs):
          print('do some stuff')
  &gt;       result = func(*args, **kwargs)
  
  test.py:20:
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  
      @dec
      def test_something_is_not_true():
  &gt;       assert False
  E       assert False
  
  test.py:31: AssertionError
  ---------------------------- Captured stdout call -----------------------------
  do some stuff
  ===================== 1 failed, 1 passed in 0.11 seconds ======================
  </code></pre>
  
  <p>As you can see, the decorator function is not really doing anything... but if I could get that to work then I could see if the test passed in that function and if so, perform some extra logic based on the result of the pass or fail of the test. Perhaps using Decorators to accomplish capture the output of a test isn't the best way to do it? </p>
  
  <p>What would you do?</p>