vendredi 25 mars 2016

Flask. Dispatcher Middleware testing.

We can obtain test_client for sample application in way like:

class MyTestCase(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        my_app.app.config['TESTING'] = True
        cls.client = my_app.app.test_client()

However, if we wrap app with DispatcherMiddleware - we will get error like AttributeError: 'DispatcherMiddleware' object has no attribute 'test_client'.

Are there way to test composition of flask applications?

We want to be able to do something like:

cls.client = my_app.all_apps.test_client()

When all_apps is middleware like:

all_apps = DispatcherMiddleware(my_app, {
    '/backend': backend_app,
})

Aucun commentaire:

Enregistrer un commentaire