【发布时间】:2016-03-25 12:21:25
【问题描述】:
我们可以通过以下方式获取test_client作为示例应用程序:
class MyTestCase(unittest.TestCase):
@classmethod
def setUpClass(cls):
my_app.app.config['TESTING'] = True
cls.client = my_app.app.test_client()
但是,如果我们用 DispatcherMiddleware 包装应用程序 - 我们会得到类似的错误
AttributeError: 'DispatcherMiddleware' object has no attribute 'test_client'.
有没有办法测试烧瓶应用程序的组成?
我们希望能够做这样的事情:
cls.client = my_app.all_apps.test_client()
当all_apps 是中间件时:
all_apps = DispatcherMiddleware(my_app, {
'/backend': backend_app,
})
【问题讨论】: