Turbogears2 和 py.test
我将测试环境从 Nose 切换到 py.test 以测试 Turbogears2 Web 应用程序。
目前,当 Nose 运行时,它会从测试配置文件 (test.ini) 收集信息,该文件包含应用程序所需的所有测试变量。它似乎以自动方式执行此操作(我只是运行 nosetests
并且所有内容都已加载)
问题依赖于 py.test 无法指向正确的 INI 配置文件,以便我可以让应用程序加载我需要的变量。
目前,失败点是 pylons.app_globals,在运行 py.test 时它根本不存在(因此一切都会失败)。
我已经阅读了 Turbogears 文档,但他们只提到了 Nose/nosetests 而没有其他任何内容。
有没有办法能够使用我依赖的 py.test 测试变量来引导应用程序?
I'm switching our testing environment from Nose to py.test for testing a Turbogears2 web application.
Currently, when Nose runs it gathers information from a testing configuration file (test.ini) that holds all the testing variables the application needs. And it seems to do so in an automatic way (I'm simply running nosetests
and everything gets loaded)
The problem relies in the inability for py.test to be pointed at the right INI configuration file so that I can get the app loaded with the variables I need.
Currently, the failing point is pylons.app_globals which is simply non-existent when running py.test (hence everything fails).
I have been through the Turbogears documentation but they only mention Nose/nosetests and nothing else.
Is there a way to be able to lead the application with the testing variables I rely upon with py.test ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就 py.test 的部分而言,您可以实现如下所示的内容:
这样的 conftest.py 文件目前最好位于您的结帐根目录中,因为 py-1.3.4 仅在足够早地看到它时才会运行此挂钩。
我还查看了一点 TurboGears,但没有轻易找到 test.ini 实际加载的机制。如果有人可以提供此信息,我可以更新答案。
HTH。霍尔格
As far as py.test's part is concerned, you can implement something like this:
Such a conftest.py file should currently best live at your checkout root directory as py-1.3.4 will only run this hook if it sees it early enough.
I also looked a bit around TurboGears but didn't erasily found the mechanism how/which test.ini is actually loaded. I can update the answer if somebody can provide this information.
HTH. Holger