猿问

根据ini文件中的设置为金字塔Web应用程序编写doctest

我想编写文档测试我的金字塔的web应用程序,使用WebTest的模块。我这样尝试过:


from my_webapp import main

from webtest import TestApp


app = TestApp(main({}))

result = app.get('/')

当我的代码到达此行时,这会引发KeyError(因为some.url未知):


url = request.registry.settings['some.url']

的值some.url是在我的应用程序的paste ini文件中指定的。development.ini运行测试代码时,有没有一种使用我的简单方法?我尚未完全了解金字塔启动过程中ini文件的加载方式/加载时间,因此很难在测试时确定将文件加载到何处。


Smart猫小萌
浏览 171回答 1
1回答
随时随地看视频慕课网APP

相关分类

Python
我要回答