Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经看到了,这建议直接解析配置信息:
将**设置信息从鼻子传递给单元测试
...但这仍然需要我对“test.ini”进行硬编码。如何通过鼻子测试将配置文件的名称传递给我的应用程序?
Pylons 过去通过注册一个特殊的 nose 插件来做到这一点,该插件将--with-pylons=test.ini选项添加到 nose。我可能建议只使用文件名设置一个环境变量并以这种方式处理它。
--with-pylons=test.ini
export TEST_INI="test.ini" env/bin/nosetests
import os ini_file = os.environ['TEST_INI']