{"id":34096072,"url":"https://github.com/jonking93/pytest-error","last_synced_at":"2026-03-12T06:01:43.192Z","repository":{"id":327701842,"uuid":"1110271788","full_name":"JonKing93/pytest-error","owner":"JonKing93","description":"Decorator to validate pytest tests that should raise expected exceptions","archived":false,"fork":false,"pushed_at":"2025-12-06T04:06:53.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-24T14:23:45.639Z","etag":null,"topics":["exceptions","pytest","testing"],"latest_commit_sha":null,"homepage":"https://jonking93.github.io/pytest-error/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JonKing93.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-05T00:34:18.000Z","updated_at":"2025-12-06T03:55:00.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/JonKing93/pytest-error","commit_stats":null,"previous_names":["jonking93/pytest-error"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/JonKing93/pytest-error","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonKing93%2Fpytest-error","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonKing93%2Fpytest-error/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonKing93%2Fpytest-error/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonKing93%2Fpytest-error/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JonKing93","download_url":"https://codeload.github.com/JonKing93/pytest-error/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonKing93%2Fpytest-error/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30416733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T04:41:02.746Z","status":"ssl_error","status_checked_at":"2026-03-12T04:40:12.571Z","response_time":114,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["exceptions","pytest","testing"],"created_at":"2025-12-14T15:27:05.754Z","updated_at":"2026-03-12T06:01:43.181Z","avatar_url":"https://github.com/JonKing93.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pytest-error\n\nA decorator for testing exceptions with [pytest](https://docs.pytest.org/en/stable/index.html).\n\n\n## About\n\nThe `pytest-error` package provides an `@error` decorator to validate pytest tests that should raise an exception. The decorator is built on the [pytest.raises][pytest.raises] context manager, and further extends its functionality to allow validation of error messages using strings. ([pytest.raises][pytest.raises] requires regular expressions to validate error messages).\n\nSome motivations for using the decorator include:\n\n1. Testing error messages without needing regular expressions\n2. Adding a marker to quickly identify tests that examine error states\n3. Keeping the [action code][test anatomy] for exception tests at the same indent level as other tests\n\n[pytest.raises]: https://docs.pytest.org/en/stable/how-to/assert.html#assertions-about-expected-exceptions\n[test anatomy]: https://docs.pytest.org/en/stable/explanation/anatomy.html\n\n## Examples\n\nRequire a test to raise an expected exception:\n\n```python\nfrom pytest_error import error\n\n@error(ValueError, \"some message A\", \"another message B\", \"final message C\")\ndef test():\n    raise ValueError(\n        \"This test must raise an ValueError whose error message \"\n        \"must include some message A, another message B, and a final message C.\"\n    )\n\n@error((TypeError, ValueError), 'some message')\ndef test_multiple_types():\n    raise TypeError(\n        \"This test must raise either a TypeError or ValueError, \"\n        \"and the error must include some message\".\n    )\n```\n\nAuto-fail and display the raised message in the pytest results (useful for examining error messages when writing tests):\n```python\n@error(RuntimeError)\ndef test():\n    raise RuntimeError(\n        \"Because @error does not include any error message strings, \"\n        \"this test will fail and will display the raised error message \"\n        \"in the pytest output. Refer to the documentation for ways to \"\n        \"disable auto-failing.\"\n    )\n```\n\nPlays well with the pytest ecosystem:\n```python\n@error(TypeError, 'some error message')\n@pytest.mark.parametrize('parameter', (1,2,3))\ndef test_with_parameters(parameter):\n    raise TypeError(\n        'This test uses parameters, and should raise a TypeError with some error message'\n    )\n\n@error(ValueError, 'some error message')\ndef test_with_fixtures(fixtureA, fixtureB):\n    raise ValueError(\n        'This test uses fixtures, and should raise a ValueError with some error message'\n    )\n    \nclass TestClass:\n    @error(RuntimeError, 'some error message')\n    def test_that_is_a_method(cls):\n        raise RuntimeError(\n            'This test is a class method, and should raise a RuntimeError with some error message'\n        )\n\n@error((ValueError, TypeError), 'some message', check=some_callable, match=some_regex)\ndef test_raises_api():\n    raise ValueError(\n        \"This exception raised by this test must satisfy the `check` and `match` args \"\n        \"from the pytest.raises API, and must raise a ValueError with some message.\"\n    )\n```\n\nInject parameters and fixtures into expected error messages:\n```python\n@error(ValueError, 'message including {param1} and {fixture2}')\n@pytest.mark.parametrize(\n    'param1', ('some message A', 'some message B')\n)\ndef test(param1, fixture1, fixture2):\n    raise ValueError(\n        f'This test should raise an exception that has a message '\n        f'including {param1} and {fixture2}'\n    )\n```\n\n## Installation\n\n**Requires**: Python 3.10+, pytest 8.4+\n\n```\npip install pytest-error\n```\n\n## Documentation\n\nYou can find more detailed examples, a user guide, and a comprehensive API at the [project documentation](https://jonking93.github.io/pytest-error).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonking93%2Fpytest-error","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonking93%2Fpytest-error","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonking93%2Fpytest-error/lists"}