I write this according to flaskr sample, I can login with browser,but test fails. Thanks for your help!
@app.route('/login', methods=['GET', 'POST'])
def login():
error = None
if request.method == 'POST':
username = request.form['username']
password = request.form['password']
if lib.authenticate_user(username, password):
session['logged_in'] = True
flash('You were logged in')
return render_template('www.html')
return render_template('login.html', error=error)
tests.py
def login(self, username, password):
#print username, password
return self.app.post('/Login', data=dict(
username=username,
password=password
), follow_redirects=True)
# testing functions
def test_login_logout(self):
"""Make sure login and logout works"""
rv = self.login('c1','123')
assert 'You were logged in' in rv.data