pytest-raises
An implementation of pytest.raises as a pytest.mark fixture
Decision gist · record as of 2026-08-14
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.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires pytest 2.8.1 or above; test function body with @pytest.mark.setup_raises must be exactly 'pass' (no other code allowed).
- 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 · maintenance · safety
(unclear) — License treatment is unclear—no SPDX identifier or raw license text provided in metadata, making legal terms ambiguous for redistribution or modification.
last release 2020-04-23 (2304 days) · last repo commit 2023-09-29 · 20 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 159,704 downloads/mo, #10,691 on PyPI
Alternatives
Verify before relying
pip install pytest-raises
import pytest
@pytest.mark.raises(exception=ValueError)
def test_something():
raise ValueError('expected error')- 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.
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 on this page. Verify before relying on it.
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
pytest-raises on PyPI
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.
Requires pytest 2.8.1 or above; test function body with @pytest.mark.setup_raises must be exactly 'pass' (no other code allowed).
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')
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 | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagepytest |
| Maintenance | Dormant 2,304 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 159,704 / month, #10,691 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
Evidence: pytest_raises-0.11-py2.py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “pytest exception assertion decorator”
- pytest-raisesProvides pytest markers (@pytest.mark.raises and…
- pytest-reraiseCaptures exceptions raised in threads during pytest tests and…
- flake8-pytest-styleA flake8 plugin that detects and reports style inconsistencies and…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.
Install it if you write tests for any asyncio-based code.
A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.
Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.
See also pytest-reraise · pytest-lazy-fixture · flake8-pytest-style · pytest-fail-slow · pytest-check · parametrize · pytest-runtime-xfail · pytest-order · pytest-codeblocks