【问题标题】:Pass command line arguments to nose via "python setup.py test"通过“python setup.py test”将命令行参数传递给nose
【发布时间】:2016-10-05 11:34:51
【问题描述】:

包设置

我已经构建了一个 Python 包,它使用 nose 进行测试。因此,setup.py 包含:

..
test_suite='nose.collector',
tests_require=['nose'],
..

python setup.py test 按预期工作:

running test
...
----------------------------------------------------------------------
Ran 3 tests in 0.065s

OK

使用 XUnit 输出运行

由于我使用的是 Jenkins CI,我想将鼻子结果输出为 JUnit XML 格式:

nosetests <package-name> --with-xunit --verbose

不过,python setup.py test 更加优雅,它无需构建虚拟环境即可安装测试需求。

当通过python setup.py test 调用nose 时,有没有办法将--with-xunit(或任何其他参数)传递给nose?

【问题讨论】:

    标签: python command-line-arguments nose setup.py


    【解决方案1】:

    您可以使用 setup.cfg 设置鼻子测试选项

    比如在你setup.cfg

    [nosetests]
    with-xunit=1
    

    更多信息请访问http://nose.readthedocs.io/en/latest/api/commands.html

    【讨论】:

      【解决方案2】:

      Nose 提供了自己的 setuptools 命令 (nosetests),它接受命令行参数:

      python setup.py nosetests --with-xunit
      

      更多信息可以在这里找到: http://nose.readthedocs.io/en/latest/setuptools_integration.html

      【讨论】:

        猜你喜欢
        • 2016-10-25
        • 1970-01-01
        • 1970-01-01
        • 2021-11-29
        • 1970-01-01
        • 2013-06-03
        • 2015-03-23
        • 2014-04-27
        • 2011-03-04
        相关资源
        最近更新 更多