简体   繁体   English

如何以编程方式为鼻子指定xml输出

[英]How to specify xml output for nose programatically

I am running tests from a script with Nose. 我正在使用Nose的脚本运行测试。 I want to be able to specify the xunit xml output file. 我希望能够指定xunit xml输出文件。 The documentation says I can do it with the --xunit-file=FILE option. 文档说我可以使用--xunit-file = FILE选项。

I have 我有

noseargs = ['--with-xunit', '--xunit-file=output.xml', '--tests=mytest']
nose.run(argv=noseargs)

After running this, the output.xml file isn't there. 运行此命令后,output.xml文件不存在。 I've found if I swap the two arguments so it looks like: 我发现如果我交换这两个参数,它看起来像:

noseargs = ['--xunit-file=output.xml', '--with-xunit', '--tests=mytest']
nose.run(argv=noseargs)

it will create a nosetests.xml file in my working directory. 它将在我的工作目录中创建一个nosetests.xml文件。 So it looks like the --with-xunit argument needs to be processed first, then the file needs to be specified. 所以看起来需要首先处理--with-xunit参数,然后需要指定文件。 Is there something particular about how the file should be specified that I'm missing? 有没有什么特别的关于如何指定我丢失的文件?

Nose eats the first argument of argv because on the commandline it's the name of the program. Nose吃了argv的第一个参数,因为在命令行上它是程序的名称。

This works with: 这适用于:

noseargs = ['foo', '--with-xunit', '--xunit-file=output.xml', '--tests=mytest']
nose.run(argv=noseargs)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM