vendredi 27 mars 2015

Flask-related class testing

I have couple of mixins for my Flask-powered application. Most of them not blueprints or view, but classes inherited object and imed to be mixed into real JSON-answering views.


For example, one class could read parameters from request object and convert it to specified type.


I'd like to test itself (not real view which includes this mixin). Ideally for me is to prepare request context object (maybe with test_request_context) at the top of contextes stack with some predefined parameters. But I do not understand how to do it.


test_request_context prepares empty request (i.e. request.form is empty immutable dict). I tried to use EnvironmentBuilder but failed due insufficien knowledge of werkzeug internals.


Is there way to populate test request with data?


Aucun commentaire:

Enregistrer un commentaire