Contents
Join the Testing In Python (TIP) mailing list for Python testing tools discussions!
This wiki page is originated from PyCheeseCake and it was originally created by Grig Gheorghiu
Unit Testing Tools
Tool |
Category |
Author |
Part of |
Claim to fame |
unit testing |
first unit test framework to be included in Python standard library; easy to use by people familiar with the xUnit frameworks; strong support for test organization and reuse via test suites |
|||
unit testing |
copy and paste output from shell session; Agile Documentation: unit tests themselves can serve as documentation when combined with epydoc; also see Django's approach |
|||
unit testing |
It used to be named py.test which was part of the pylib. Standalone now. |
no API!;automatic collection of tests; simple asserts; strong support for test fixture/state management via setup/teardown hooks; strong debugging support via customized traceback |
||
unittest extensions |
|
unit test framework, used most notably by TurboGears and Pylons; provides an alternate test discovery and running process for unittest, one that is intended to mimic the behavior of py.test as much as is reasonably possible without resorting to too much magic. More friendly with unittest.TestCase-based tests than py.test. There are also many plugins available. |
||
unittest extensions |
|
unit test framework, provides Enhanced test fixture setup, Split test suites into buckets for easy parallelization, PEP8 naming conventions & Fancy color test runner with lots of logging / reporting option. |
||
unittest extensions |
Extension of unittest to support writing asynchronous unit tests using Deferreds and new result types ('skip' and 'todo'). Includes a command-line program that does test discovery and integrates with doctest and coverage. |
|||
unittest extensions |
|
Transparently adds support for running unittest test cases/suites in a separate process : prevents system wide changes by a test destabilising the test runner. It also allows reporting from tests in another process into the unittest framework, giving a single integrated test environment. |
||
unittest extensions |
|
Provides a mechanism for managing 'resources' - expensive bits of infrastructure - that are needed by multiple tests. Resources are constructed and free on demand, but with an optional TestSuite?, the test run order is optimised to reduce the number of resource constructions and releases needed. Compatible with unittest. |
||
unit testing |
|
Provides class based test Fixtures, in which several (usually interrelated) objects that need to be set up for tests are lumped together on a single object, called a Fixture. Fixtures are reusable and can depend on other Fixtures in turn. Fixtures can be used with any test framework, but easy integration is provided for pytest. A few other test utilities are included as well. |
||
unittest extensions |
|
Useful extensions to unittest derived from custom extensions by projects such as Twisted and Bazaar. |
||
unit testing |
Sancho 2.1 runs tests, and provides output for tests that fail; Sancho 2.1 does not count tests passed or failed; targets projects that do not maintain failing tests |
|||
unit testing |
Zope3 community |
|
Powerful test runner that includes support for post-mortem debugging of test failures. Also includes profiling and coverage reporting. This is a standalone package that has no dependencies on Zope and works just fine with projects that don't use Zope. |
|
unit testing |
|
Elegant unit testing framework with built-in coverage analysis, profiling, micro-benchmarking and a powerful command-line interface. |
||
unit testing |
|
Tool that will automatically, or semi-automatically, generate unit tests for legacy systems written in Python. |
||
unittest extensions |
logilab-common |
Gives more power to standard unittest. More assert* methods; support for module level setup/teardown; skip test feature... |
||
tests runner |
logilab-common |
Tests finder / runner. Selectivly run tests; Stop on first failure; Run pdb on failed tests; Colorized reports; Run tests with coverage / profile enabled... |
||
unittest extensions |
PyOOP package (distributed separately too) |
An object oriented interface to retrieve unittest test cases out of doctests. Hides initialization from doctests by allowing setUp and tearDown for each interactive example. Allows control over all the options provided by doctest. Specialized classes allow selective test discovery across a package hierarchy. |
The following tools are not currently being developed or maintained as far as we can see. They are here for completeness, with last activity date and an indication of what documentation there is. If you know better, please edit.
Tool |
Last Activity |
Category |
Author |
Claim to fame |
2009 |
unittest extensions |
unittest enhancements; test filtering via regex/glob patterns; reporting in XML/HTML; colorized output; runs pdb on failing tests; run in parallel in threads/processes; verbose asserts; report failures immediately; and a little more; |
||
2009 |
performance-based unit testing |
port of JUnitPerf; transparently adds performance testing capabilities to existing unitttest-based test suites |
||
2008 |
specification-based unit testing |
like the unittest module, except that test methods may take arguments; you declare each argument with a default value which names a test-data generator and the peckcheck module will peck at your test methods with a bunch of generated values |
||
2008 |
unit testing |
A manly test runner; command-line and curses(3) interfaces; the iPod of test runners. (More seriously, makes it easier to browse and inspect your test failures) |
||
2004 |
unit testing |
Easy-to-use (PyQt) GUI framework and application for use with the Python unit testing framework. It can be used to conveniently execute unit tests and suites, and then display the results in a useful fashion. |
Mock Testing Tools
See also here for a side-by-side syntax comparison between some of the more popular tools in this space.
Tool |
Category |
Author |
Claim to fame |
mocks, stubs, spy, and dummies |
Gustavo Rezende |
Elegant test doubles framework in Python (mocks, stubs, spy, and dummies) |
|
mock testing |
Python Mock enables the easy creation of mock objects that can be used to emulate the behaviour of any class that the code under test depends on. You can set up expectations about the calls that are made to the mock object, and examine the history of calls made. This makes it easier to unit test classes in isolation. Download it here. |
||
mock testing |
PyMock is based on the Java easymock package. It uses a recording and replay model rather than using a specification language. Easymock lives up to its name compared to other mocking packages. PyMock takes advantage of python's dynamic nature for futher improvements. |
||
mock testing |
Michael Foord aka Fuzzyman |
Provides "action -> assertion" mocking patter, instead of standard "record -> replay" pattern |
|
mock testing |
Graham Carlyle |
Inspired by the Java jMock library, pMock makes the writing of unit tests using mock object techniques easier. Development of pmock has long since stopped and so it can be considered dead. |
|
mock testing |
Embeds mock testing constructs inside doctest tests. |
||
mock testing |
enables easier testing of Python programs that make use of Subversion's Python bindings |
||
mock testing |
Graceful platform for test doubles in Python (mocks, stubs, fakes, and dummies). Well-documented and fairly feature-complete. |
||
stub testing |
Stubble allows you to write arbitrary classes for use as stubs instead of read classes while testing. Stubble lets you link a stub class loosely to the real class which it is a stub for. This information is then used to ensure that tests will break if there is a discrepancy between the interface supported by your stub class and that of the real class it stands in for. |
||
mock testing |
smiddlek, dglasser |
Mox is based on EasyMock, a Java mock object framework. Mox will make mock objects for you, so you don't have to create your own! It mocks the public/protected interfaces of Python objects. You set up your mock objects expected behavior using a domain specific language (DSL), which makes it easy to use, understand, and refactor! |
|
mock testing |
Tim Cuthbertson (gfxmonk) |
Mocktest allows you to mock / stub objects and make expectations about the methods you expect to be called as well as the arguments they should be called with. Expectations are very readable and expressive, and checked automatically. Any stubbed methods are reverted after each test case. Still under development, so subject to change |
|
mock and stub testing |
A module for using fake objects (mocks, stubs, etc) to test real ones. Uses a declrative syntax like jMock whereby you set up expectations for how an object should be used. An error will raise if an expectation is not met. |
||
mock and stub testing |
A port of the Mockito mocking framework to Python. (Technically speaking, Mockito is a Test Spy framework.) |
||
mock testing |
Geoff Bache |
True record-replay approach to mocking. Requires no coding, just telling it which modules/attributes you want to mock. Then stores the behaviour in an external file, which can be used to test the code without those modules installed. |
|
mock/stub/spy testing and fake objects |
Port of the popular Ruby mocking library to Python. Includes automatic integration with most popular test runners. |
||
easy and powerful stubs, spies and mocks |
Free and restricted doubles using hamcrest matchers for all assertions. It provides a wrapper for the pyDoubles framework. |
||
spies and mock responses |
