Integrating the nose2 library
nose2 is a library that makes testing easier and much more fun. It provides a whole lot of tools to enhance our tests. Although nose2
can be used for multiple purposes, the most important usage remains that of a test collector and runner. nose2
automatically collects tests from Python source files, directories, and packages found in the current working directory. In this recipe, we will focus on how to run individual tests using nose2
rather than the whole bunch of tests every time.
Important
In earlier editions of this book, we used the nose
library. It has since not been under active maintenance and can be deemed deprecated. A replacement for it has been created, with the name nose2
. This library behaves similarly to nose
but is not exactly the same. However, for the purpose of our demonstration, the major functionality remains similar.
Getting ready
First, we need to install the nose2
library:
$ pip install nose2
nose2
has a mechanism...