[Flask] Flask. Application Factory Testing

Nicolas Le Manchet nicolas at lemanchet.fr
Thu Oct 11 04:37:29 EDT 2018


Hi,

While you have an app factory (create_app), you still define a global app object and use it to create your routes. This defeats a bit the purpose of the app factory and makes writing tests more difficult.

One way to solve this problem is by using blueprints, they allow you to decouple the views from the app so you can define your routes without having a concrete app object. You then bind the blueprint with the app inside the create_app function.

- http://flask.pocoo.org/docs/1.0/tutorial/views/
- https://github.com/miguelgrinberg/flasky/blob/master/app/__init__.py#L36

-- 
Nicolas Le Manchet


More information about the Flask mailing list