Using nose for unified test discovery and reporting
Note that nose
is a third-party tool available via pip
and Python Package Index. It does basically the same job as a unittest discover
command, but it supports more control and customization as well as recognizing a wider range of tests. It can be installed using the following command line:
python3 -m pip install nose
Running our tests with nose
We're going to look at two specific features among the many that nose provides. These are:
- It can generate a code coverage report that tells us how much of the code our test actually tested
- It can run tests across multiple processes, allowing them to be executed in parallel on multiple CPUs
In order to get a coverage report, we first need to make sure that the coverage module is installed. We could do this with a simple pip
command, as follows:
python3 -m pip install coverage
Once we have the coverage
module in place, we can enable a coverage report for our test with nothing more than a couple of nose's...