python - 如何以编程方式为 nose 指定 xml 输出

标签 python nose

我正在使用 Nose 从脚本运行测试。我希望能够指定 xunit xml 输出文件。文档说我可以使用 --xunit-file=FILE 选项来完成。

我有

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

运行后,output.xml 文件不存在了。我发现如果我交换这两个参数,它看起来像:

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

它将在我的工作目录中创建一个 nosetests.xml 文件。所以看起来需要先处理 --with-xunit 参数,然后需要指定文件。关于应该如何指定我缺少的文件有什么特别之处吗?

最佳答案

Nose 吃掉 argv 的第一个参数,因为在命令行上它是程序的名称。

这适用于:

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

关于python - 如何以编程方式为 nose 指定 xml 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14969265/

相关文章:

带有(子)进程覆盖率报告的 python unittest

Django 1.8 和 Nose : conflicting models?

python - 用 Nose 重复单次或多次测试

python - 如何在套件的测试类中共享一个 webdriver 实例?我使用 Selenium2 和 Python

python - Pydub - 如何在不改变播放速度的情况下改变帧率

python - Nose 测试 : Does it set the errorlevel to 1 on failure?

python - Django Nose 这个测试怎么写?

python - 使用python从doc文件中获取大写/小写的特定单词?

Python 2.7 - 使用 +01 :00 转换日期时间

python - 使用上下文管理器连接到 sqlite3 数据库