title: I'm lost with trying to write tests to my Flask application
body: <p>So I've tried writing some tests for my Flask application for a couple of days but I can't get it to run. The tests pass but it gets stuck on PASSED.</p>
  
  <p>I've cloned cookiecutter-flask (<a href="https://github.com/sloria/cookiecutter-flask" rel="nofollow">cookiecutter-flask</a>) and it runs webtest together with pytest (I think). My <em>conftest.py</em> looks the same as it does in the repo (<a href="https://github.com/sloria/cookiecutter-flask/blob/master/%7B%7Bcookiecutter.app_name%7D%7D/tests/conftest.py" rel="nofollow">conftest.py</a>)</p>
  
  <p>These are my current tests:</p>
  
  <pre><code>def test_app(testapp):
      app = create_app(TestConfig)
      res = testapp.get('/')
      res.status_code == 200
  </code></pre>
  
  <p>This pass and it continues.</p>
  
  <pre><code>def test_create_admin_user(db, testapp):
      password = bcrypt.generate_password_hash('test')
  
      User.create(
          uid='00000000000000000000',
          email='john@doe.com',
          password=password,
          active=1
      )
  
      user = User.query.filter_by(email='j@d.com').first()
  
      assert user.email == 'j@d.com'
  </code></pre>
  
  <p>This is where I'm lost and the test gets stuck on PASSED and doesn't do anything. When I force interrupt the process I get this:</p>
  
  <pre><code>Traceback (most recent call last):
    File "manage.py", line 68, in &lt;module&gt;
      manager.run()
    File "/home/johan/Development/venv_python/local/lib/python2.7/site-packages/flask_script/__init__.py", line 412, in run
      result = self.handle(sys.argv[0], sys.argv[1:])
    File "/home/johan/Development/venv_python/local/lib/python2.7/site-packages/flask_script/__init__.py", line 383, in handle
      res = handle(*args, **config)
    File "/home/johan/Development/venv_python/local/lib/python2.7/site-packages/flask_script/commands.py", line 216, in __call__
      return self.run(*args, **kwargs)
    File "/home/johan/Development/venv_python/local/lib/python2.7/site-packages/flask/ctx.py", line 386, in __exit__
      self.auto_pop(exc_value)
    File "/home/johan/Development/venv_python/local/lib/python2.7/site-packages/flask/ctx.py", line 374, in auto_pop
      self.pop(exc)
    File "/home/johan/Development/venv_python/local/lib/python2.7/site-packages/flask/ctx.py", line 357, in pop
      % (rv, self)
  AssertionError: Popped wrong request context.  (&lt;RequestContext 'http://localhost/' [GET] of backend.app&gt; instead of &lt;RequestContext 'http://localhost/' [GET] of backend.app&gt;)
  </code></pre>
  
  <p>I've found the following thread in flask about testing (granted, this is Flask-Testing but I thought that it has some relevance, maybe it doesn't: <a href="https://github.com/jarus/flask-testing/issues/21" rel="nofollow">issue</a>) and changed my test-config so it contains <em>PRESERVE_CONTEXT_ON_EXCEPTION = False</em> but it still just hangs.</p>
  
  <p>Anybody have any ideas I can try?
  I'm not super familiar with testing per se so it probably is something that I'm doing wrong.</p>