unittest

unittest is the built-in (since version 2.1) testing framework for Python. It is modelled after the excellent JUnit framework for Java, and the xUnit testing frameworks in general. This makes for a clean, object-oriented style.

Important concepts

unittest supports the standard unit testing parts in a straightforward manner. The following concepts map onto functional elements:

  • Test case: This is an individual test or group of tests. All tests in a test case belong to the same class and share a fixture.
  • Test fixture: The functions required to do setUp and tearDown for all the test cases in a class.
  • Test suite: This is a collection of test cases. Test cases in a test suite are meant to be run together.
  • Test runner: This is a component that runs ...

Get Mastering IPython 4.0 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.