asserts
Stand-alone Assertions
What it is and what it does
asserts is a lightweight library of assertion functions designed to work independently of unittest.TestCase. Instead of inheriting from TestCase to get assertion methods, you import assertion functions directly—useful in test classes that don't derive from TestCase, in mock and fake implementations, or as a richer alternative to Python's built-in assert statement. The library includes common assertions like assert_equal, assert_true, and assert_raises, all with customizable failure messages and PEP 8 compliance.
The package trades away a couple of TestCase features (custom assertion classes and addTypeEqualityFunc support) for cleaner separation of concerns: your test runner handles test execution, and assertion functions handle validation. It depends only on typing-extensions and requires Python 3.10 or later.
Use it for:
- Write assertions in test classes that don't inherit from unittest.TestCase.
- Add rich assertion checks to mock and fake object implementations.
- Use assertions in production code as a more readable alternative to the assert statement.
- Customize assertion failure messages with format strings for clearer test output.
- Build custom assertion functions by extending the library's assertion patterns.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides stand-alone assertion functions for Python that work outside unittest.TestCase, suitable for test cases, mocks, fakes, and implementations with customizable failure messages.
Yes, if you need stand-alone assertions outside unittest.TestCase. The package is actively maintained, has low install friction, and carries no known vulnerabilities. However, verify the license before use in proprietary contexts, and note that it is classified as Alpha—suitable for testing and development but not yet marked as stable.
Install
asserts on PyPI
pip
pip install assertsuv
uv add assertspoetry
poetry add assertsInstalling asserts
Before you install
Low friction install with a single runtime dependency (typing-extensions). Active maintenance with a recent release (270 days ago) and ongoing repository activity.
License in practice
License status is unclear—no SPDX identifier or raw license text is available in the package metadata. Verify the actual license before use in proprietary or restricted contexts.
Quickstart
pip install asserts
from asserts import assert_equal, assert_true, assert_raises
assert_equal(13, 13)
assert_true(True, msg="custom message")
with assert_raises(KeyError):
raise KeyError()
Requires Python 3.10 or later.
Verify before relying
- Whether the package is suitable for production use given its 'Alpha' development status classification.
- What the actual license is, since license_treatment is marked unclear and no SPDX or raw license text is provided.
Package facts
| License | not declared (unclear) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing-extensions |
| Maintenance | actively maintained — 270 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 106,072/month — #12,669 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: asserts-0.14.0-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
delayed-assertCollects multiple assertion failures in a test…
unclear · top 15,000 on PyPI
re-assertProvides a helper class for regex assertions…
permissive · top 15,000 on PyPI
TestSlideTestSlide is a test framework for Python that…
permissive · top 15,000 on PyPI
softestSoftest extends unittest.TestCase to allow…
unclear · top 15,000 on PyPI
testtoolstesttools extends Python's standard unittest…
permissive · top 5,000 on PyPI
ensureensure provides literate assertion helpers for…
permissive · top 5,000 on PyPI
assertpyProvides a fluent assertion API for writing…
permissive · top 5,000 on PyPI
testpathTestpath provides utilities for testing code…
permissive · top 5,000 on PyPI
pytest-assumeA pytest plugin that collects and reports…
permissive · top 15,000 on PyPI
expecttestexpecttest implements inline golden tests where…
permissive · top 5,000 on PyPI