re-assert
show where your regex match assertion failed!
What it is and what it does
re-assert wraps regex pattern matching to provide readable failure diagnostics in test assertions. When a pattern fails to match, it shows the exact position in the input string where the match broke down, with visual markers pointing to the failure point. This is especially useful in pytest, where the overridden equality operator integrates directly into assertion output; for other test frameworks, the `assert_matches()` method produces similarly clear tracebacks.
Under the hood, re-assert uses the regex library (which is a drop-in replacement for Python's built-in re module) to compile and match patterns. You construct a Matches object with a pattern string or an already-compiled regex, then use it like a normal value in equality assertions or call `assert_matches()` directly. The library is designed to be lightweight and requires only the regex dependency.
Use it for:
- Write pytest tests for regex patterns with clear failure messages showing exactly where the match failed.
- Debug regex patterns during development by seeing the precise mismatch point instead of a generic False result.
- Test compiled regex objects from existing code without rewriting the pattern as a string.
- Use in non-pytest test frameworks via the assert_matches() method for readable regex validation errors.
- Validate input patterns in data pipelines where regex failures need to be quickly diagnosed.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a helper class for regex assertions that shows exactly where and why a pattern match failed, integrating with pytest and other test frameworks.
Yes. It is a focused, well-maintained tool with no security issues, low install friction, and a permissive license. If you write regex-based tests in pytest or other frameworks, it directly improves test readability and debugging speed with minimal overhead.
Install
re-assert on PyPI
pip
pip install re-assertuv
uv add re-assertpoetry
poetry add re-assertInstalling re-assert
Before you install
Low friction: pure Python wheel with a single runtime dependency on regex. Actively maintained with a recent commit in July 2026.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open and closed projects.
Quickstart
pip install re-assert
from re_assert import Matches
# In a pytest test:
assert Matches('foo') == 'food' # passes
assert Matches('foo') == 'fork' # fails with clear diagnostic
# Or with assert_matches():
Matches('foo').assert_matches('food')
Requires Python 3.6.1 or later; regex library must be installed (handled by pip).
Verify before relying
- Whether regex library's 100% compatibility claim with re library extends to all edge cases in practice.
- Performance characteristics when used with complex patterns or large volumes of assertions.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.6.1) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — regex |
| Maintenance | actively maintained — 2,362 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 80,461/month — #14,290 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: re_assert-1.1.0-py2.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
assertsProvides stand-alone assertion functions for…
unclear · top 15,000 on PyPI
dirty-equalsProvides custom equality matchers that make…
permissive · top 5,000 on PyPI
pytest-assumeA pytest plugin that collects and reports…
permissive · top 15,000 on PyPI
pytest-regexA pytest plugin that selects tests to run using…
permissive · top 15,000 on PyPI
pytest-unorderedProvides a pytest assertion helper to compare…
permissive · top 5,000 on PyPI
pytest-deepassertA pytest plugin that replaces standard…
permissive · top 15,000 on PyPI
ensureensure provides literate assertion helpers for…
permissive · top 5,000 on PyPI
delayed-assertCollects multiple assertion failures in a test…
unclear · top 15,000 on PyPI
pytest-mypy-pluginsA pytest plugin that runs type-checking tests…
permissive · top 15,000 on PyPI
pytest-reraiseCaptures exceptions raised in threads during…
permissive · top 15,000 on PyPI