title: py.test to test flask register, AssertionError: Popped wrong request context
body: <p>I'm using flask to do register and login:</p>
  
  <pre><code>from flask.ext.security.views import register, login
  
  class Register(Resource):
      def post(self):
          return register()
  
  class Login(Resource):
      def post(self):
          return login()
  
  api.add_resource(Login, '/login')
  api.add_resource(Register, '/register')
  </code></pre>
  
  <p>then I use py.test to test the class:</p>
  
  <pre><code>class TestAPI:
      def test_survey(self, app):
          client = app.test_client()
          data = {'email': 'test@test', 'password': 'password'}
          rv = client.post('/2014-10-17/register',
                            data=json.dumps(data))
          ...
  </code></pre>
  
  <p>when I ran the test, the error occurred as follow:</p>
  
  <pre><code>AssertionError: Popped wrong request context.  (&lt;RequestContext 'http://localhost/2014-10-17/register' [POST] of panel.app&gt; instead of &lt;RequestContext 'http://localhost/' [GET] of panel.app&gt;)
  </code></pre>
  
  <p>Do you know why? And when testing login, there was no such error</p>