在Python测试脚本中将选项传递给鼻子 [英] Passing options to nose in a Python test script
问题描述
我不是使用命令行运行鼻子测试,而是使用了一个测试运行程序,该运行程序为所有测试设置了一些内容,包括与MongoDB本地测试实例的连接.鼻子的文档似乎仅指示如何通过命令行或位于主目录中的配置文件传递选项.使用脚本运行测试时,是否可以传递选项,例如--with-xunit?
Rather than running my nose tests from the command line, I'm using a test runner that sets up a few things for all the tests, including a connection to a local test instance of MongoDB. The documentation for nose only seems to indicate how to pass options through the command line or a configuration file located in your home directory. Is there a way to pass options, such as --with-xunit when using a script to run your tests?
推荐答案
像这样:
import nose
argv = ['fake', '--with-xunit']
nose.main(argv=argv)
必须添加"fake"参数以代表可执行文件名称,如dbw的答案所述.
The "fake" argument must be added to stand in for the executable name, as described in dbw's answer.
这篇关于在Python测试脚本中将选项传递给鼻子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!