Python nose

From wikinotes

Nose isn't a unit-testing module, but a unit-testing discovery module. It is designed to be run from the command-line, and has vim plugins (yesss). Nose works by matching all files matching the configured testMatch regex string. For a test to be run, it's module, file, function/class names must match testMatch. Also, nose expects unit-tests, so it only runs classes if they re subclasses of unittest.TestCase. By default, nose does not run executable files, you can modify this behavior with the --exe flag.


WARNING:

nose is no longer being maintained, see nose2.


Usage

nosetests test.module									               ## Run TestModule directly
nosetests /path/to/module.py: test_function		               ## Run Specific test within module only
nosetests --rednose path/to/file.py:Test_Class.test_function   ## Run a Specific test only


Plugins

Rednose (colour)

A wonderful extension to nose which displays colour in your results

sudo pip install rednose

nosetests --rednose /path/to/module.py

dnose

I wrote myself a little bash function so that I don't need to keep constantly navigating to my tests directory. If I am running a python module, I can re-run it with dnose and the test will be run instead of the python module.

## See ~/.bash/aliases/all