--- id: pytest-raises version: "0.11" license: unclear license_treatment: unclear maintenance: dormant --- # pytest-raises — An implementation of pytest.raises as a pytest.mark fixture License: unclear · Maintenance: dormant · Downloads: 159.7K/mo ## What it is and what it does pytest-raises is a pytest plugin that lets you mark test functions with decorators to assert they raise expected exceptions. Instead of wrapping code in a `with pytest.raises(...)` context manager, you decorate the entire test function with `@pytest.mark.raises()` or `@pytest.mark.setup_raises()` to declare that an exception should be raised during test execution or setup, respectively. The plugin accepts optional parameters to specify the exception type, match the exception message by substring or regex, and apply regex flags. The main use case is marking tests (especially in parametrized test suites) where raising an exception is the expected behavior—the test passes only if the exception is raised. It also provides `@pytest.mark.setup_raises()` for the uncommon case where you need to verify that an exception occurs during pytest's setup phase rather than during the test itself. The package depends only on pytest and installs with low friction, but has been dormant since 2020 with no recent maintenance. Use it for: - Mark parametrized test cases where different parameters should raise different exception types, using pytest.param with the marker. - Assert that fixture setup or custom pytest hooks raise expected errors during the pytest_runtest_setup phase. - Replace verbose `with pytest.raises(...)` blocks with a cleaner decorator syntax for entire test functions. - Verify that code raises a specific exception type with a message matching a regex pattern or substring. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides pytest markers (@pytest.mark.raises and @pytest.mark.setup_raises) to assert that test code raises expected exceptions, functioning as a decorator alternative to pytest.raises context managers. Yes, if you are already on pytest 2.8.1+ and want decorator-based exception assertions instead of context managers. However, exercise caution: the package is dormant (last release 2020-04-23), so compatibility with modern pytest versions is unverified, and the license is unclear. Test it in a non-critical project first, or consider whether the built-in `with pytest.raises(...)` context manager meets your needs instead. ## Install pip install pytest-raises uv add pytest-raises poetry add pytest-raises ## Installing pytest-raises Before you install: Low install friction with a single pytest dependency. Package is dormant (last release 2020-04-23, no commits since 2023-09-29), so expect no active maintenance or updates. License in practice: License treatment is unclear—no SPDX identifier or raw license text provided in metadata, making legal terms ambiguous for redistribution or modification. Quickstart: pip install pytest-raises import pytest @pytest.mark.raises(exception=ValueError) def test_something(): raise ValueError('expected error') Requires pytest 2.8.1 or above; test function body with @pytest.mark.setup_raises must be exactly 'pass' (no other code allowed). Verify before relying: - Whether the package is compatible with modern pytest versions (last release was 2020-04-23). - Actual Python version support range—metadata lists 'python 2.7 or above' but requires_python is empty. - Whether dormant status and lack of recent commits indicate compatibility issues with current test frameworks. ## Package facts - License: not declared (unclear) - Python support: unspecified - Install friction: low - Maintenance: dormant - Downloads: 159.7K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags pytest exception assertion decorator, pytest mark raises plugin, test expected exceptions pytest, pytest raises marker, assert exception raised pytest, pytest setup phase exception testing, pytest-plugin, exception-testing [View on SkillFed](https://skillfed.io/packages/pytest-raises) · [View on PyPI](https://pypi.org/project/pytest-raises/)