问题
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