PyHamcrest
Hamcrest framework for matcher objects
Decision gist · record as of 2026-08-14
Yes. PyHamcrest is stable (Production/Stable status), widely used (6393524 monthly downloads), has no dependencies, and carries a permissive BSD License. The aging maintenance status (last release 2023-10-22) is not a blocker for a mature, focused library—it indicates stability rather than abandonment. Install it if you want more readable, maintainable test assertions.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low install friction with no runtime dependencies.
- Maintenance status is aging—last release was 2023-10-22 and last commit 2026-02-12, but the repository remains active and not archived.
License · maintenance · safety
permissive license (permissive) — BSD License (permissive). You can use, modify, and distribute PyHamcrest freely in commercial and private projects, provided you retain the copyright notice and disclaimer.
last release 2023-10-22 (1027 days) · last repo commit 2026-02-12 · 804 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 6,393,524 downloads/mo, #1,916 on PyPI
Alternatives
Verify before relying
pip install PyHamcrest
from PyHamcrest import assert_that, equal_to
import unittest
class MyTest(unittest.TestCase):
def test_example(self):
assert_that(5, equal_to(5))- Whether the import path is 'hamcrest' or 'PyHamcrest' in current versions
What it is and what it does
PyHamcrest is a matcher framework that lets you write test assertions as declarative rules rather than imperative comparisons. Instead of writing brittle equality checks, you compose matchers to express exactly what aspect of an object you're testing and to what precision. This helps tests stay readable and maintainable: they fail when behavior deviates from expectations but pass through minor, unrelated changes.
The library comes with matchers for objects, numbers, text, sequences, dictionaries, and logical combinations. You can also write custom matchers by subclassing BaseMatcher. PyHamcrest integrates naturally with unittest and other test frameworks. It has no runtime dependencies and supports Python 3.6 and later across CPython, PyPy, and Jython.
Use it for
- Write unit tests with readable, composable assertions that fail precisely when behavior changes.
- Validate UI or form input by matching against patterns for strings and regular expressions.
- Filter or validate data structures using reusable matcher logic across multiple test cases.
- Create custom matchers for domain-specific validation rules to eliminate test code duplication.
- Build flexible test suites that distinguish between critical behavior changes and minor implementation details.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
PyHamcrest is stable (Production/Stable status), widely used (6393524 monthly downloads), has no dependencies, and carries a permissive BSD License. The aging maintenance status (last release 2023-10-22) is not a blocker for a mature, focused library—it indicates stability rather than abandonment. Install it if you want more readable, maintainable test assertions.
Install
pyhamcrest on PyPI
Before you install
Low install friction with no runtime dependencies. Maintenance status is aging—last release was 2023-10-22 and last commit 2026-02-12, but the repository remains active and not archived.
License in practice
BSD License (permissive). You can use, modify, and distribute PyHamcrest freely in commercial and private projects, provided you retain the copyright notice and disclaimer.
Quickstart
pip install PyHamcrest
from PyHamcrest import assert_that, equal_to
import unittest
class MyTest(unittest.TestCase):
def test_example(self):
assert_that(5, equal_to(5))
Verify before relying
- Whether the import path is 'hamcrest' or 'PyHamcrest' in current versions
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3.6 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Aging 1,027 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 6,393,524 / month, #1,916 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: JythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software DevelopmentTopic :: Software Development :: Quality AssuranceTopic :: Software Development :: Testing |
Evidence: pyhamcrest-2.1.0-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 › “matcher framework for testing”
- PyHamcrestPyHamcrest provides a framework for writing declarative matcher…
- expectsExpects is an assertion library for TDD/BDD that lets you write test…
- libsastlibsast is a static application security testing library that scans…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also anys · dirty-equals · assertpy · surer · re-assert · callee · testtools · robotframework-assertion-engine · asserts · expects