# samuelcolvin/dirty-equals

Doing dirty (but extremely useful) things with equals.

Repository: https://github.com/samuelcolvin/dirty-equals
Canonical: https://ross.abutalabs.com/products/dirty-equals
Homepage: https://dirty-equals.helpmanual.io
Language: Python
License: MIT
License Family: permissive
Topics: python, pytest, unit-testing, testing-tools
Last push: 2026-08-10T11:48:55+00:00

## Health v2 (maintenance only)
Score: 75/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 97, release rhythm 33, longevity 100
- inputs: {"age_days": 1680, "days_push": 23, "days_rel": 290, "gap_med": 154.0, "n_releases_24m": 3}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1004, forks 54 (observed 2026-09-03T02:15:17.640988+00:00)

## What it is
dirty-equals is a Python library that overloads __eq__ to provide declarative, partial-match assertion helpers for unit tests. It lets you compare values against matchers like IsPositiveInt, IsStr(regex=...), IsJson, and IsNow instead of exact values.

## Use cases
- assert API response fields without knowing exact values
- test database row contents declaratively
- match strings against regexes in assertions
- compare JSON strings by decoded value
- check datetimes are close to now in tests
- partially match dicts and lists in pytest

## When to choose
- writing pytest unit tests that assert on API responses or DB rows
- you want readable, declarative assertions with partial matching
- you need regex, type, or fuzzy datetime comparisons inside assert statements

## When to avoid
- non-Python projects
- production code where magic __eq__ semantics would be confusing
- tests requiring strict exact-value equality only

## Facets
- artifact type: library
- maturity: active
- function: testing, developer-tools
- domain: testing, developer-tools
- platform: python, cross-platform
- tags: pytest, unit-testing, assertions, declarative-tests, matchers

## Member repositories
- samuelcolvin/dirty-equals (main) score 75

## Provenance
- Observed fields: from GitHub, fetched 2026-09-03T02:15:17.640988+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T07:13:46.802772+00:00, confidence not recorded.
  - readme: https://github.com/samuelcolvin/dirty-equals (fetched 2026-09-03T02:15:17.640988+00:00, sha e08357dbf42b)
  - homepage: https://dirty-equals.helpmanual.io (fetched 2026-08-29T13:13:30.704869+00:00, sha d78d824cb680)
  - registry_pypi: https://pypi.org/pypi/dirty-equals/json (fetched 2026-08-29T13:13:30.714282+00:00, sha 06efabf39edf)
- Data as of 2026-08-30T08:39:29.467469+00:00.
