Search code examples
pythoncommand-line-argumentsnosesetup.py

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


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?


Solution

  • 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