mitsuhiko/flask — Issue #400: code errors at http://flask.pocoo.org/docs/testing/#testing
Author: arohacs
Created: 2012-02-07 18:34:24+00:00
State: open

The flaskr_tests.py app as constructed by the code on the page will fail all 3 tests. I copied the source file at https://github.com/mitsuhiko/flask/blob/master/examples/flaskr/flaskr_tests.py and it runs all tests successfully. A vimdiff showed the following issues between the files (I hope the formatting isn't mangled too badly - if so, it's not hard to copy, paste, and do another vimdiff):

source file from github: code from tutorial:
https://github.com/mitsuhiko/flask/blob/ http://flask.pocoo.org/docs/testing/#testing
master/examples/flaskr/flaskr_tests.py

---------------------------------------------------------------------------------------------------------------------------------------

def tearDown(self): def tearDown(self):
"""Get rid of the database again after each test

os.unlink(flaskr.app.config['DATABASE']) os.unlink(flaskr.DATABASE)
os.unlink(flaskr.app.config['DATABASE']) os.unlink(flaskr.DATABASE)

def test_login_logout(self): def test_login_logout(self):
"""Make sure login and logout works"""
rv = self.login(flaskr.app.config['USERNAME'], rv = self.login('admin', 'default')
flaskr.app.config['PASSWORD'])

rv = self.login(flaskr.app.config['USERNAME'] + rv = self.login('adminx', 'default')
flaskr.app.config['PASSWORD'])

rv = self.login(flaskr.app.config['USERNAME'], rv = self.login('admin', 'defaultx')
flaskr.app.config['PASSWORD'] +

def test_messages(self): def test_messages(self):
"""Test that messages work""" self.login('admin', 'default')
self.login(flaskr.app.config['USERNAME'],
flaskr.app.config['PASSWORD'])