I'm using flask to do register and login:
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')
then I use py.test to test the class:
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))
...
when I ran the test, the error occurred as follow:
AssertionError: Popped wrong request context. (<RequestContext 'http://localhost/2014-10-17/register' [POST] of panel.app> instead of <RequestContext 'http://localhost/' [GET] of panel.app>)
Do you know why? And when testing login, there was no such error