code errors at http://flask.pocoo.org/docs/testing/#testing #400

Closed
arohacs opened this Issue Feb 7, 2012 · 5 comments

Projects

None yet

5 participants

arohacs commented Feb 7, 2012

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'])

Contributor
rduplain commented Feb 7, 2012

Thanks for reporting this. Any interest in posting a pull request? I'll file another issue to run the example tests in the Flask core test runner.

-Ron

arohacs commented Feb 7, 2012

Sure, I'd be happy to help, but I'm a bit new with github. Please excuse my newness - how should I go about this?

Thanks,

-Adam

Contributor
rduplain commented Feb 7, 2012

This is a good opportunity to get into git/github. Start here:
http://help.github.com/fork-a-repo/

I'm always online on IRC, though not always at the keyboard. I'm rduplain.
http://flask.pocoo.org/community/irc/

You'll also find a lot of help/fast-response online for general git/github questions. If you decide to pass, just let me know and I'll apply your diff.

-Ron

remram44 commented Aug 8, 2014

The flaskr example doesn't seem to run at all now:

Traceback (most recent call last):
  File "flaskr_tests.py", line 12, in <module>
    import flaskr
  File "flask/examples/flaskr/flaskr.py", line 48, in <module>
    @app.cli.command('initdb')
AttributeError: 'Flask' object has no attribute 'cli'

@remram44 this is because you are using Flaskr from the master branch and have a different version of Flask installed.

@DasIch DasIch closed this Aug 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment