pytest-reraise
Make multi-threaded pytest test cases fail when they should
What it is and what it does
pytest-reraise is a pytest plugin that solves a specific threading problem: when you write assertions inside a thread spawned from a test, those assertions fail silently because the exception is raised in the thread, not the main test thread. The plugin provides a `reraise` fixture that acts as a context manager to capture exceptions from worker threads and re-raise them in the main thread at the end of the test, making the test fail as expected.
The plugin supports wrapping functions as decorators, manually triggering re-raises mid-test, handling multiple exceptions (keeping the first), optionally catching exceptions to prevent them from crashing the thread, and accessing or resetting captured exceptions. It's designed for developers writing multi-threaded tests who need pytest to properly detect assertion failures that occur in spawned threads.
Use it for:
- Testing concurrent code where worker threads perform assertions that must be validated by the main test
- Verifying that background tasks or thread pools fail correctly when they encounter errors
- Debugging multi-threaded applications by ensuring thread exceptions don't silently pass tests
- Wrapping thread target functions with exception capture to keep threads alive while collecting errors
- Comparing captured thread exceptions against expected error types or messages in test assertions
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Captures exceptions raised in threads during pytest tests and re-raises them in the main thread so that multi-threaded test failures are properly detected.
Yes, if you actively write multi-threaded pytest tests and need thread exceptions to fail your tests. The low install friction and permissive license make adoption easy. However, the abandoned maintenance status (last commit 2023-02-06) is a concern—verify compatibility with your pytest and Python versions before relying on it for new projects, and monitor for any unresolved issues with newer releases.
Install
pytest-reraise on PyPI
pip
pip install pytest-reraiseuv
uv add pytest-reraisepoetry
poetry add pytest-reraiseInstalling pytest-reraise
Before you install
Low friction: pure Python wheel with only pytest as a runtime dependency. Maintenance is stalled—last commit was 2023-02-06 and the package is marked abandoned, though it remains marked Production/Stable and has received no security reports.
License in practice
MIT license is permissive; you may use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install pytest-reraise
# In your test file:
from threading import Thread
def test_with_thread(reraise):
def run():
with reraise:
assert False
Thread(target=run).start()
Verify before relying
- Whether the package works reliably with pytest versions released after 2023-02-06
- Whether the abandoned status indicates unresolved bugs or compatibility issues with newer Python or pytest releases
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.6.1,<4.0.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pytest |
| Maintenance | abandoned — 1,424 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 180,427/month — #10,145 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_reraise-2.1.2-py3-none-any.whl
Keywords: pytest, plugin, threads, exception, assert, catch, raise, re-raise
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
outcomeCaptures the outcome of Python function…
permissive · top 1,000 on PyPI
pytest-assumeA pytest plugin that collects and reports…
permissive · top 15,000 on PyPI
pytest-raisesProvides pytest markers (@pytest.mark.raises…
unclear · top 15,000 on PyPI
pytest-raceProvides a pytest fixture that runs test…
permissive · top 15,000 on PyPI
re-assertProvides a helper class for regex assertions…
permissive · top 15,000 on PyPI
pytest-run-parallelA pytest plugin that runs test functions…
permissive · top 15,000 on PyPI
softestSoftest extends unittest.TestCase to allow…
unclear · top 15,000 on PyPI
kthreadKThread provides a way to forcefully terminate…
permissive · top 15,000 on PyPI
pytest-rerunfailuresA pytest plugin that automatically reruns…
copyleft · top 1,000 on PyPI
pytest-checkA pytest plugin that allows tests to continue…
unclear · top 5,000 on PyPI