testtools
Extensions to the Python standard library unit testing framework
What it is and what it does
testtools is a mature extension library for Python's unittest that adds custom matchers (reusable assertion predicates), fixture lifecycle management, and rich test result reporting. It lets you attach arbitrary diagnostic data to test failures—log files, system state, environment details—making debugging easier when tests fail in production-like conditions.
The library prioritizes compatibility with the standard library while providing advanced features like parametrized exception handling, multi-result aggregation, and test cloning. It works with Python 3.10+ and PyPy3, making it suitable for projects that need unittest's ecosystem but want more expressive assertions and better failure diagnostics without switching to an entirely different test framework.
Use it for:
- Writing custom matchers for domain-specific assertions in integration or acceptance tests.
- Attaching log files, metrics, or environment snapshots to test results for post-mortem debugging.
- Building test frameworks or libraries that extend unittest while remaining compatible with standard tools.
- Testing server or service code where fixture setup/teardown and detailed failure context are critical.
- Projects requiring PyPy3 or Python 3.10+ support while staying within the unittest ecosystem.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
testtools extends Python's standard unittest framework with custom matchers, fixture management, detailed test result reporting, and cross-Python compatibility for Python 3.10+.
Yes. testtools is production-stable, actively maintained, has no dependencies, and solves real problems in unittest-based projects: custom matchers reduce boilerplate, fixture management simplifies setup/teardown, and rich result reporting cuts debugging time. Install it if you're committed to unittest and want better assertions and diagnostics without migrating to pytest.
Install
testtools on PyPI
pip
pip install testtoolsuv
uv add testtoolspoetry
poetry add testtoolsInstalling testtools
Before you install
Low install friction with no runtime dependencies. Actively maintained with a recent release (112 days ago) and ongoing repository activity. Supports current Python versions (3.10+).
License in practice
Licensed under MIT (permissive), allowing free use, modification, and distribution with minimal restrictions.
Quickstart
pip install testtools
from testtools import TestCase
from testtools.matchers import Equals
class MyTest(TestCase):
def test_example(self):
self.assertThat(7 * 7, Equals(49))
Requires Python 3.10 or later.
Verify before relying
- Whether the matcher ecosystem is large enough for common assertion patterns in your project.
- Performance characteristics compared to standard unittest or pytest for large test suites.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 112 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,838,139/month — #3,499 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: testtools-2.9.1-py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
xunitparserParses JUnit/XUnit XML test result files and…
permissive · top 15,000 on PyPI
assertsProvides stand-alone assertion functions for…
unclear · top 15,000 on PyPI
testfixturesTestfixtures provides helpers and mock objects…
permissive · top 5,000 on PyPI
oslotestoslotest provides a testing framework with…
permissive · top 15,000 on PyPI
xmlunittestExtends Python's unittest framework to compare…
permissive · top 5,000 on PyPI
unittest2Backports unittest features from Python 2.7 and…
permissive · top 5,000 on PyPI
PyHamcrestPyHamcrest provides a framework for writing…
permissive · top 5,000 on PyPI
approvaltestsApprovalTests provides a snapshot-based…
permissive · top 15,000 on PyPI
testresourcestestresources extends unittest to manage…
permissive · top 15,000 on PyPI
approval-utilitiesProvides utility functions and helpers for…
permissive · top 15,000 on PyPI