pytest-deepassert
A pytest plugin for enhanced assertion reporting with detailed diffs
What it is and what it does
pytest-deepassert is a pytest plugin that intercepts assertion failures and replaces the default comparison output with structured, readable diffs generated by deepdiff. When you enable it with the --deepassert flag, any failed assertion on complex data structures—dictionaries, lists, nested objects, custom types—shows you exactly which fields differ, what values changed, and where items were added or removed, rather than dumping a wall of text that requires manual parsing.
The plugin is designed as an opt-in enhancement: it does not interfere with normal pytest behavior unless you explicitly pass --deepassert at runtime. It handles basic types (int, string, float, bool), collections (dict, list, tuple, set, frozenset), and advanced types (OrderedDict, NamedTuple, custom objects), and claims to work with pytest.approx() and mock.ANY for flexible comparisons. The implementation depends on deepdiff for the heavy lifting, pytest for the plugin interface, and typing-extensions for compatibility.
Use it for:
- Debugging test failures on API responses or database records where only a few nested fields differ from expected.
- Comparing large configuration dictionaries or JSON payloads where visual diff clarity matters more than raw output.
- Testing mock objects with ANY placeholders or approximate float comparisons that standard assertions struggle to report clearly.
- Reducing time spent reading assertion diffs in CI logs by getting a structured, path-based view of what changed.
- Validating complex domain objects or data transfer objects where the structure is deeply nested and changes are subtle.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pytest plugin that replaces standard assertion failures with detailed, structured diffs powered by DeepDiff, making it easier to spot differences in complex nested data structures.
Yes, with conditions. Install if you regularly debug test failures on complex nested data and want clearer diffs without rewriting assertions. The low install friction and permissive license make it a safe experiment. However, the aging maintenance status (283 days since last release, 11 stars) means the project has limited community traction and may not receive timely fixes; use it in projects where you can tolerate slower response to issues. The opt-in flag design means you can enable it selectively without affecting existing test suites.
Install
pytest-deepassert on PyPI
pip
pip install pytest-deepassertuv
uv add pytest-deepassertpoetry
poetry add pytest-deepassertInstalling pytest-deepassert
Before you install
Low friction: pure Python wheel with only three runtime dependencies (deepdiff, pytest, typing-extensions). Maintenance status is aging—last release was 283 days ago and the project has 11 stars—so expect infrequent updates and limited community validation.
License in practice
MIT license (permissive): you can use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install pytest-deepassert
# In your test file:
import pytest
def test_example():
expected = {"name": "Alice", "age": 30}
actual = {"name": "Bob", "age": 30}
assert expected == actual
# Run with: pytest --deepassert your_test.py
Requires pytest 6.0+ and Python 3.8+; the plugin is opt-in via the --deepassert flag and does not activate by default.
Verify before relying
- How well does the plugin handle pytest.approx() and mock.ANY in practice across different data nesting levels?
- What is the performance impact on test suites with very large nested structures?
- Are there known limitations or edge cases with custom comparator utilities beyond what the description lists?
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — deepdiff, pytest, typing-extensions |
| Maintenance | aging — 283 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 133,296/month — #11,522 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_deepassert-0.3.0-py3-none-any.whl
Keywords: assertions, debugging, diff, plugin, pytest, testing
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
pytest-assumeA pytest plugin that collects and reports…
permissive · top 15,000 on PyPI
pytest-clarityA pytest plugin that displays colored,…
permissive · top 15,000 on PyPI
re-assertProvides a helper class for regex assertions…
permissive · top 15,000 on PyPI
pytest-checkA pytest plugin that allows tests to continue…
unclear · top 5,000 on PyPI
deepdiffDeepDiff compares dictionaries, iterables,…
permissive · top 1,000 on PyPI
deepdiff6DeepDiff recursively compares two Python…
permissive · top 15,000 on PyPI
pytest-parametrizationProvides decorator-based parametrization for…
permissive · top 15,000 on PyPI
pytest-unorderedProvides a pytest assertion helper to compare…
permissive · top 5,000 on PyPI
assertsProvides stand-alone assertion functions for…
unclear · top 15,000 on PyPI
snob-libSnob analyzes your Python project's dependency…
permissive · top 15,000 on PyPI