py.test to test flask register, AssertionError: Popped wrong request context
It's a known flask problem. You receive two exceptions instead one. Simply add PRESERVE_CONTEXT_ON_EXCEPTION = False
to your test config.
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)) ...
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.