Python testing with nose

nose makes testing for Python easier. It is a fairly well known Python discovery-based unittest extension that can run doctests, unittests, “no boilerplate” tests and provides xUnits, generators and fixtures.

nose makes testing for Python easier. It is a fairly well-known Python discovery-based unittest extension that can run doctests, unittests, “no boilerplate” tests and provides xUnits, generators and fixtures.

Unit testing is an automated code-level testing method that tests each unit of program’s code. Its aim is to ensure that all parts of the program are correct, meet their design and work properly. Unit tests are quick and easy to run, can be the source of executable documentation for function and API. They help developers to improve the quality of delivered code, especially if it is a part of Test Driven Development, where unit tests are written prior to the functionality they're testing.

There are a lot of ways to integrate unit tests into development cycle and developers use a wide range of unit test discovery and execution frameworks in order to add tests to existing code, execute them, and get a comprehensible report. Why use specifically nose? First of all, its syntax is not complicated and you can start testing code quickly and without much thinking. nose keeps things simple: no boilerplate code, no unnecessary imports, no required classes to drive from, and no extra API.

Secondly, nose has a really great plug-in architecture that allows to extend functionality in a convenient way. It is fully compatible with Python unittest, integrates well with distutils and can be adapted to mimic any other unit test discovery framework. Moreover, nose comes with a stack of built-in plugins and plugin hooks that allow to customize any part of testing. Choose how to load, run, and watch tests; specify formats of test run reports and collect any additional information about tests (like code coverage or profiling data); modify or override output handling, test discovery, and test execution; improve code coverage, output capture, error introspection, doctests, and much more.

nose is one of the most widely used unittest frameworks that provides automatic test discovery and plenty of plugins for features like xUnit-compatible test output, coverage reporting, and test selection. Find more on nose.readthedocs.org.

Connect with our experts Let's talk