I\'m using flask to do register and login:
from flask.ext.security.views import register, login
class Register(Resource):
def post(self):
return
It seems that you have to wrap you testing calls with something like this:
with self.app.test_client() as client:
data = {'email': 'test@test', 'password': 'password'}
rv = client.post('/2014-10-17/register', data=json.dumps(data))
...
In my case, I've went to the flask.ctx.AppContext.__exit__ method and discovered that there was an invisible, unhandled exception in the exc_value argument which has somehow broken the whole thing to pieces.
It's a known flask problem. You receive two exceptions instead one. Simply add PRESERVE_CONTEXT_ON_EXCEPTION = False to your test config.
When your testA has a syntax error or other exceptions, the tearDown() method which does the context pop job will not be reached, so the testA's context wasn't popped correctly. Then your next test we call it testB will pop the testA's context. So, that's why you got the error AssertionError: Popped wrong request context..
Check the error in your test code, fix it. Then the AssertionError will be gone automatically.