Flask-testing - why the test does fail
Your views.py
file mount the routes in the app
created in your __init__.py
file.
You must bind these routes to your created app in create_app
test method.
I suggest you to invert the dependency. Instead the views.py
import your code, you can make a init_app
to be imported and called from your __init__.py
or from the test file.
# views.pydef init_app(app): app.add_url_rule('/', 'index', index) # repeat to each route
You can do better than that, using a Blueprint.
def init_app(app): app.register_blueprint(blueprint)
This way, your test file can just import this init_app
and bind the blueprint to the test app
object.