Book Image

Python Essentials

By : Steven F. Lott
Book Image

Python Essentials

By: Steven F. Lott

Overview of this book

Table of Contents (22 chapters)
Python Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using other add-on test libraries


The doctest and unittest modules allow us to write a number unit tests conveniently. In many cases, we want even more sophistication. One of the more popular additional features is test discovery. The nose package gives us a way to painlessly examine modules and packages for tests. See http://nose.readthedocs.org/en/latest/ for more information.

There are several benefits of using nose as an extension to unittest. The nose module can collect tests from unittest.TestCase subclasses, as well as simple test functions, and also from test classes that are not subclasses of unittest.TestCase. We can use nose for writing timing tests too—something that can be a little awkward in unittest.

Because nose is particularly good at collecting tests automatically, there's no need to manually collect test cases into test suites; we don't need some of the examples shown earlier. Furthermore, nose supports test fixtures at the package, module, and class level, so expensive...