title: testing decorator with pytest using weird syntax
body: <p>so I wanted to test a decorator that gives you a coroutine that's primed up (so I don't have to do <code>coroutine.send(None)</code> ).</p>
  
  <p>Details can be found <a href="http://www.dabeaz.com/coroutines/coroutine.py" rel="nofollow noreferrer">here</a>. David Beazley's example)</p>
  
  <p>so in conftest.py I created a function wrapper that's a pytest fixture, which gives me a raw coroutine, if that makes sense.</p>
  
  <p>the reason I am doing this is because pytest will take anything after yield keyword as teardown codes and I don't want that. so I wrapp up a raw coroutine myself.</p>
  
  <pre><code>@pytest.fixture(scope="module")
  def create_coroutine_func():
  
      def grep(pattern):
          print "Looking for %s" % pattern
          while True:
              line = (yield)
              if pattern in line:
                  print line
      return grep
  </code></pre>
  
  <p>now in my test file I have a rather simple test:</p>
  
  <pre><code>    from something.decorators import *
      import pytest
  
  1    def test_coroutine(create_coroutine_func):
  2        coro_func = create_coroutine_func()
  3        coro_wrapper = coroutine(coro_func)
  4    
  5        assert callable(coro_wrapper)
  </code></pre>
  
  <p>ok that's it. pytest complained:</p>
  
  <blockquote>
    <p>create_coroutine() missing 1 required positional argument: 'pattern'</p>
  </blockquote>
  
  <p>then I went ahead edited line 2:</p>
  
  <pre><code>coro_func = create_coroutine_func("python") # match anything has 'python' in it.
  </code></pre>
  
  <p>now test passed. </p>
  
  <p>now I a bit confused with decorators now.</p>
  
  <p>So in my example grep takes an argument; when I call my grep function wrapper, I need to give the function wrapper an argument as well although it doesn't take any argument itself? is this how decorator works?</p>