Pass command line arguments to nose via "python setup.py test"
<h1>Package Settings</h1>

<p>I have built a Python package which uses <a href="http://nose.readthedocs.io/en/latest/" rel="nofollow">nose</a> for testing. Therefore, <a class='doc-link' href="http://stackoverflow.com/documentation/python/1381/creating-python-packages#t=201610051128088238533"><code>setup.py</code></a> contains:</p>

<pre><code>..
test_suite='nose.collector',
tests_require=['nose'],
..
</code></pre>

<p>And <code>python setup.py test</code> works as expected:</p>

<pre><code>running test
...
----------------------------------------------------------------------
Ran 3 tests in 0.065s

OK
</code></pre>

<h1>Running with XUnit output</h1>

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

<pre><code>nosetests &lt;package-name&gt; --with-xunit --verbose
</code></pre>

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

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

<p>Nose provides its own setuptools command (<code>nosetests</code>) which accepts command line arguments:</p>

<pre><code>python setup.py nosetests --with-xunit
</code></pre>

<p>More information can be found here:
<a href="http://nose.readthedocs.io/en/latest/setuptools_integration.html" rel="nofollow">http://nose.readthedocs.io/en/latest/setuptools_integration.html</a></p>

python command-line-arguments nose setup.py