nosetests setuptools command

The easiest way to run tests with nose is to use the nosetests setuptools command:

python nosetests

This command has one major benefit over the standard test command: all nose plugins are supported.

To configure the nosetests command, add a [nosetests] section to your setup.cfg. The [nosetests] section can contain any command line arguments that nosetests supports. The differences between issuing an option on the command line and adding it to setup.cfg are:

  • In setup.cfg, the – prefix must be excluded
  • In setup.cfg, command line flags that take no arguments must be given an argument flag (1, T or TRUE for active, 0, F or FALSE for inactive)

Here’s an example [nosetests] setup.cfg section:


If you commonly run nosetests with a large number of options, using the nosetests setuptools command and configuring with setup.cfg can make running your tests much less tedious. (Note that the same options and format supported in setup.cfg are supported in all other config files, and the nosetests script will also load config files.)

Another reason to run tests with the command is that the command will install packages listed in your tests_require, as well as doing a complete build of your package before running tests. For packages with dependencies or that build C extensions, using the setuptools command can be more convenient than building by hand and running the nosetests script.


If you are distributing your project and want users to be able to run tests without having to install nose themselves, add nose to the setup_requires section of your setup():

    # ...

This will direct setuptools to download and activate nose during the setup process, making the nosetests command available.


convert a optparse option list into a distutils option tuple list