{"id":21859,"library":"re-assert","title":"re-assert","description":"A library to show where your regex match assertion failed. It provides a helper to clarify regex failures in tests. Current version: 1.1.0, release cadence: low, maintained by asottile.","status":"active","version":"1.1.0","language":"python","source_language":"en","source_url":"https://github.com/asottile/re-assert","tags":["regex","testing","assertion","debugging"],"install":[{"cmd":"pip install re-assert","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"note":"ReAssert is the main class for assertion with better error messages.","symbol":"ReAssert","correct":"from re_assert import ReAssert"}],"quickstart":{"code":"from re_assert import ReAssert\n\n# Pattern with group names\npattern = r\"(?P<name>\\w+) (?P<age>\\d+)\"\nmatcher = ReAssert(pattern)\n\n# This assertion will fail with a detailed message\n# matcher == 'John 30 extra'\n# Uncomment to see error: matcher == 'John 30' (this matches)","lang":"python","description":"Basic usage: create a ReAssert object with a regex pattern, then compare with a string. If match fails, it prints where and why."},"warnings":[{"fix":"Use 'matcher == string' pattern.","message":"ReAssert uses __eq__ to perform matching. Ensure you are comparing the ReAssert object to a string, not the other way around.","severity":"gotcha","affected_versions":"all"},{"fix":"Use in test suites with pytest or unittest.","message":"The library is designed for testing; it does not raise exceptions but returns False and prints diagnostic info. Do not use it for production regex validation without assertions.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use 'from re_assert import ReAssert' (note underscore)","cause":"Incorrect import: the module is named re_assert (with underscore), not re-assert (with hyphen).","error":"ImportError: cannot import name 're_assert'"},{"fix":"Run 'pip install re-assert' and import with 'from re_assert import ReAssert'","cause":"Version mismatch or incorrect installation. Ensure package is installed as 're-assert'.","error":"AttributeError: module 're_assert' has no attribute 'ReAssert'"},{"fix":"matcher = ReAssert(pattern); then matcher == 'string'","cause":"Attempting to call ReAssert as a function. It is a class, instantiate it first.","error":"TypeError: 'ReAssert' object is not callable"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}