title: Why can't pytest find the 'client' fixture when testing a Flask app?
body: <p>I have a simple flask app, i want to test it using pytest.</p>
  
  <p>my <code>conftest.py</code>:</p>
  
  <pre><code>@pytest.fixture
  def app(self):
      app = create_app(TestingConfig)
  
      return app
  </code></pre>
  
  <p>my <code>test_view.py</code>:</p>
  
  <pre><code>class TestMainView:
  
  def test_ping(self, client):
      res = client.get(url_for('main.index'))
      assert res.status_code == 200
  </code></pre>
  
  <p>when i run the test's using <code>pytest</code> it's throwing an error saying:</p>
  
  <pre><code>fixture 'client' not found
  &gt;       available fixtures: app, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_xml_property, recwarn, tmpdir, tmpdir_factory
  &gt;       use 'pytest --fixtures [testpath]' for help on them.
  </code></pre>
  
  <p>i have another testing file where i test default configs and it passes:</p>
  
  <pre><code>class TestTestingClass(object):
  app = create_app(TestingConfig)
  
  def test_app_is_test(self):
      ''' test the test enviroment is set okay and works'''
      assert self.app.config['SECRET_KEY'] == 'something hard'
      assert self.app.config['DEBUG'] == True
      assert self.app.config['TESTING'] == True
      assert current_app is not None
      assert self.app.config['SQLALCHEMY_DATABASE_URI'] == 'sqlite:////tmp/testing.db'
  </code></pre>
  
  <p><strong>edit</strong>:
  i was able to pass an empty test by changing to:</p>
  
  <p><code>conftest.py</code>:</p>
  
  <pre><code>@pytest.fixture
  def app():
      app = create_app(TestingConfig)
  
      return app
  
  
  @pytest.fixture
  def client(app):
      return app.test_client()
  </code></pre>
  
  <p>and my test file to:</p>
  
  <pre><code>def test_index(client):
     assert True
  </code></pre>
  
  <p>but, still i can't pass the <code>test_index</code> if it was:</p>
  
  <pre><code>def test_index(client):
     assert client.get(url_for('main.index')).status_code == 200
  </code></pre>
  
  <p>but this time, I'm getting an error stating that says:</p>
  
  <pre><code>RuntimeError: Attempted to generate a URL without the application context being pushed. This has to be executed when application context is available.
  </code></pre>