AttributeError: 'module' object has no attribute 'app'
I pulled the latest master branch and ran "python setup.py install". Then, I tried to load flask.app.test_client(), but it fails. Please let me know how to overcome this. Thank you!
MOOLE04mac1231:flask moole04$ python
Python 2.7.10 (default, Feb 7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import flaskr
>>> t= flaskr.app.test_client()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'app'
>>>
Because you have to create an app in your own project. flask.app is a module in Flask that has the Flask object you use to do that.
I think he's trying to do something with flaskr
I followed what is shown in link http://flask.pocoo.org/docs/0.12/testing/. Pls see the line "self.app = flaskr.app.test_client()". So it is expected to work. Please let me know if I am wrong.
In your interpreter you need to use from flaskr import flaskr, like the test file does.
This is what I get when I try.
from flaskr import flaskr Traceback (most recent call last): File "
", line 1, in ImportError: cannot import name flaskr
You didn't install flaskr in editable mode then.
cd examples/flaskr
pip install -e .