{ "info": { "author": "Anthony Sottile", "author_email": "asottile@umich.edu", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only" ], "description": "[![Build Status](https://dev.azure.com/asottile/asottile/_apis/build/status/asottile.re-assert?branchName=master)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=31&branchName=master)\n[![Azure DevOps coverage](https://img.shields.io/azure-devops/coverage/asottile/asottile/31/master.svg)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=31&branchName=master)\n\nre-assert\n=========\n\nshow where your regex match assertion failed!\n\n## installation\n\n`pip install re-assert`\n\n## usage\n\n`re-assert` provides a helper class to make assertions of regexes simpler.\n\n### `re_assert.Matches(pattern: str, *args, **kwargs)`\n\nconstruct a `Matches` object.\n\n_note_: under the hood, `re-assert` uses the [`regex`] library for matching,\nany `*args` / `**kwargs` that `regex.compile` supports will work. in general,\n the `regex` library is 100% compatible with the `re` library (and will even\naccept its flags, etc.)\n\n[`regex`]: https://pypi.org/project/regex/\n\n### `re_assert.Matches.from_pattern(pattern: Pattern[str]) -> Matches`\n\nconstruct a `Matches` object from an already-compiled regex.\n\nthis is useful (for instance) if you're testing an existing compiled regex.\n\n```pycon\n>>> import re\n>>> reg = re.compile('foo')\n>>> Matches.from_pattern(reg) == 'fork'\nFalse\n>>> Matches.from_pattern(reg) == 'food'\nTrue\n```\n\n### `Matches.__eq__(other)` (`==`)\n\nthe equality operator is overridden for use with assertion frameworks such\nas pytest\n\n```pycon\n>>> pat = Matches('foo')\n>>> pat == 'bar'\nFalse\n>>> pat == 'food'\nTrue\n```\n\n### `Matches.__repr__()` (`repr(...)`)\n\na side-effect of an equality failure changes the `repr(...)` of a `Matches`\nobject. this allows for useful pytest assertion messages:\n\n```pytest\n> assert Matches('foo') == 'fork'\nE AssertionError: assert Matches('foo'...ork\\n # ^ == 'fork'\nE -Matches('foo')\\n\nE - # regex failed to match at:\\n\nE - #\\n\nE - #> fork\\n\nE - # ^\nE +'fork'\n```\n\n### `Matches.assert_matches(s: str)`\n\nif you're using some other test framework, this method is useful for producing\na readable traceback\n\n```pycon\n>>> Matches('foo').assert_matches('food')\n>>> Matches('foo').assert_matches('fork')\nTraceback (most recent call last):\n File \"\", line 1, in \n File \"/home/asottile/workspace/re-assert/re_assert.py\", line 63, in assert_matches\n assert self == s, self._fail\nAssertionError: regex failed to match at:\n\n> fork\n ^\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/asottile/re-assert", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "re-assert", "package_url": "https://pypi.org/project/re-assert/", "platform": "", "project_url": "https://pypi.org/project/re-assert/", "project_urls": { "Homepage": "https://github.com/asottile/re-assert" }, "release_url": "https://pypi.org/project/re-assert/1.0.0/", "requires_dist": [ "regex" ], "requires_python": ">=3.6", "summary": "show where your regex match assertion failed!", "version": "1.0.0" }, "last_serial": 5867043, "releases": { "0.0.0": [ { "comment_text": "", "digests": { "md5": "2b7089d3bb1f1ae52fefdba44caaf4ce", "sha256": "ba946d5890a3ecc02f9c3e97ef7fb229b2ed1b2d5b2e9b3b2938f272aa555033" }, "downloads": -1, "filename": "re_assert-0.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2b7089d3bb1f1ae52fefdba44caaf4ce", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6", "size": 4042, "upload_time": "2019-09-21T20:06:11", "url": "https://files.pythonhosted.org/packages/6d/2e/77f408a2a4aea8fec0634e077aa3e0537f82482a87a7477be1bdfdc811d6/re_assert-0.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1a9b477b56907e0e0cef1fa16a67e639", "sha256": "29826984bb79756cd0003a9573e76aebf3e5ee516e8553a4068e1bd3dedceac2" }, "downloads": -1, "filename": "re_assert-0.0.0.tar.gz", "has_sig": false, "md5_digest": "1a9b477b56907e0e0cef1fa16a67e639", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 3888, "upload_time": "2019-09-21T20:06:14", "url": "https://files.pythonhosted.org/packages/3a/eb/cfd74b656e6694f4e252300f4b3feb766423d313e33c13b0df7cd8766d6d/re_assert-0.0.0.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "71c40fd0943bbddd373fd975c388a15a", "sha256": "5be9d23ab05518699bf09ebdd477628c0340264190a51c75e6bf88067ea9f266" }, "downloads": -1, "filename": "re_assert-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "71c40fd0943bbddd373fd975c388a15a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6", "size": 4044, "upload_time": "2019-09-21T20:06:55", "url": "https://files.pythonhosted.org/packages/1d/06/f1fb87623b627ec66bc23457d1c47f45ec7a213e2a03fb16bad1aedc1383/re_assert-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9561a022964be9c25ac3e275de46c245", "sha256": "bc506382b1b9e77df7a6adfdd2a7d58871f7231113de0417e498dda61117c42d" }, "downloads": -1, "filename": "re_assert-1.0.0.tar.gz", "has_sig": false, "md5_digest": "9561a022964be9c25ac3e275de46c245", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 3888, "upload_time": "2019-09-21T20:06:56", "url": "https://files.pythonhosted.org/packages/d0/16/98d954270f34ce61604528d1a114ce90fc35712b20de76d8cc9192671e78/re_assert-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "71c40fd0943bbddd373fd975c388a15a", "sha256": "5be9d23ab05518699bf09ebdd477628c0340264190a51c75e6bf88067ea9f266" }, "downloads": -1, "filename": "re_assert-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "71c40fd0943bbddd373fd975c388a15a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6", "size": 4044, "upload_time": "2019-09-21T20:06:55", "url": "https://files.pythonhosted.org/packages/1d/06/f1fb87623b627ec66bc23457d1c47f45ec7a213e2a03fb16bad1aedc1383/re_assert-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9561a022964be9c25ac3e275de46c245", "sha256": "bc506382b1b9e77df7a6adfdd2a7d58871f7231113de0417e498dda61117c42d" }, "downloads": -1, "filename": "re_assert-1.0.0.tar.gz", "has_sig": false, "md5_digest": "9561a022964be9c25ac3e275de46c245", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 3888, "upload_time": "2019-09-21T20:06:56", "url": "https://files.pythonhosted.org/packages/d0/16/98d954270f34ce61604528d1a114ce90fc35712b20de76d8cc9192671e78/re_assert-1.0.0.tar.gz" } ] }