Pass command line arguments to nose via “python setup.py test”

怎甘沉沦 提交于 2019-12-23 16:30:11

问题


Package Settings

I have built a Python package which uses nose for testing. Therefore, setup.py contains:

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

And python setup.py test works as expected:

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

OK

Running with XUnit output

Since I'm using Jenkins CI, I would like to output the nose results to JUnit XML format:

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

However, python setup.py test is far more elegant, and it installs the test requirements without having to build a virtual environment.

Is there a way to pass the --with-xunit (or any other parameter) to nose, when calling nose via python setup.py test?


回答1:


Nose provides its own setuptools command (nosetests) which accepts command line arguments:

python setup.py nosetests --with-xunit

More information can be found here: http://nose.readthedocs.io/en/latest/setuptools_integration.html




回答2:


You can set nosetests option using setup.cfg

For example in you setup.cfg

[nosetests]
with-xunit=1

Further information can be found at http://nose.readthedocs.io/en/latest/api/commands.html



来源:https://stackoverflow.com/questions/39872880/pass-command-line-arguments-to-nose-via-python-setup-py-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!