skillfed

re-assert

show where your regex match assertion failed!

re-assert v1.1.0 80.5K downloads/30d#14,290 on PyPI83
Permissive license MIT Active released

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-assert

uv

uv add re-assert

poetry

poetry add re-assert

Installing 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

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8

Tags

regex assertion testingpytest regex match debuggingregex pattern validationtest regex failuresregex matching assertionspattern match error messagesregex test helper
regex-testingpytest-pluginassertion-helper

More Testing packages