dirty-equals
Doing dirty (but extremely useful) things with equals.
Decision gist · record as of 2026-08-14
Yes. dirty-equals is a low-friction, actively maintained testing utility with no dependencies that directly improves test readability and reduces boilerplate in assertion-heavy codebases. It is especially valuable for API and database testing where exact values are unknown or irrelevant. MIT license and broad Python version support make it safe to adopt.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.9 or later.
- Low friction—pure Python wheel with no runtime dependencies.
- Actively maintained with recent releases and steady community adoption (top 5000 PyPI packages).
License · maintenance · safety
MIT (permissive) — MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects.
last release 2025-11-17 (270 days) · last repo commit 2026-08-10 · 1,004 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 2,952,300 downloads/mo, #2,808 on PyPI
Alternatives
Verify before relying
pip install dirty-equals
from dirty_equals import IsPositiveInt, IsStr, IsJson
assert user_data == {
'id': IsPositiveInt,
'avatar_file': IsStr(regex=r'/[a-z0-9\-]{10}/example\.png'),
'settings_json': IsJson({'theme': 'dark'}),
}- Whether performance overhead of custom equality checks is acceptable for large test suites.
- Compatibility with test frameworks beyond pytest (unittest, nose2, etc.).
What it is and what it does
dirty-equals is a testing library that overloads Python's `__eq__` method to create reusable matcher objects for assertions. Instead of manually checking individual fields or modifying data before comparison, you write assertions that read like specifications: a field must be a positive integer, match a regex, contain specific JSON, or fall within a time window. This makes test code more declarative and maintainable, especially when validating API responses or database records with many fields.
The library provides matchers for common patterns (type checks, regex matching, partial collections, JSON parsing, timestamp proximity) and supports combining conditions with boolean operators. It has no runtime dependencies, installs cleanly as a pure Python wheel, and is actively maintained with support for Python 3.9 through 3.14.
Use it for
- Validate API response payloads without hardcoding exact values you don't control (timestamps, IDs, file paths).
- Compare database query results where you only care about certain fields or partial structure matches.
- Write readable assertions for JSON data by comparing the parsed structure rather than string matching.
- Test that response fields are the correct type without brittle exact-value checks.
- Combine multiple validation rules (e.g., 'must be a string AND match this pattern') in a single assertion.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
dirty-equals is a low-friction, actively maintained testing utility with no dependencies that directly improves test readability and reduces boilerplate in assertion-heavy codebases. It is especially valuable for API and database testing where exact values are unknown or irrelevant. MIT license and broad Python version support make it safe to adopt.
Install
dirty-equals on PyPI
Before you install
Low friction—pure Python wheel with no runtime dependencies. Actively maintained with recent releases and steady community adoption (top 5000 PyPI packages).
Requires Python 3.9 or later.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects.
Quickstart
pip install dirty-equals
from dirty_equals import IsPositiveInt, IsStr, IsJson
assert user_data == {
'id': IsPositiveInt,
'avatar_file': IsStr(regex=r'/[a-z0-9\-]{10}/example\.png'),
'settings_json': IsJson({'theme': 'dark'}),
}
Verify before relying
- Whether performance overhead of custom equality checks is acceptable for large test suites.
- Compatibility with test frameworks beyond pytest (unittest, nose2, etc.).
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 270 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,952,300 / month, #2,808 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaEnvironment :: ConsoleEnvironment :: MacOS XFramework :: PytestIntended Audience :: DevelopersIntended Audience :: EducationIntended Audience :: Information TechnologyIntended Audience :: Science/ResearchIntended Audience :: System AdministratorsLicense :: OSI Approved :: MIT LicenseOperating System :: POSIX :: LinuxOperating System :: UnixProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Topic :: InternetTopic :: Software Development :: Libraries :: Python ModulesTyping :: Typed |
Evidence: dirty_equals-0.11-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “declarative equality matching”
- dirty-equalsProvides custom equality matchers that make unit test assertions more…
- anysProvides matcher objects that compare equal to values meeting…
- attrsattrs is a Python library that automatically generates common class…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also re-assert · pytest-unordered · pyspark-test · PyHamcrest · testfixtures · jsoncomparison · assertpy · recursive-diff · django-dirtyfields · anys