Nose library integration

Nose is a library that makes testing easier and much more fun. It provides a whole lot of tools to enhance our tests. Although Nose can be used for multiple purposes, the most important usage remains that of a test collector and runner. Nose automatically collects tests from Python source files, directories, and packages found in the current working directory. We will focus on how to run individual tests using Nose rather than the whole bunch of tests every time.

Getting ready

First, we need to install the Nose library:

$ pip install nose

How to do it…

We can execute all the tests in our application using Nose by running the following command:

$ nosetests -v
Test creation of new category ... ok
Test creation of new product ...

Get Flask Framework Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.