pytest-subtests
unittest subTest() support and subtests fixture
What it is and what it does
pytest-subtests is a pytest plugin that brings unittest's subTest() context manager to pytest, plus a new subtests fixture for pure pytest tests. It lets you run multiple iterations or parameterized checks within a single test function, reporting each failure individually rather than stopping at the first one. This is useful when you want to test many similar cases (like iterating over a list of inputs) and see all failures at once instead of fixing them one by one.
The plugin depends only on pytest and attrs, and supports Python 3.9 through 3.13. It is classified as Beta and distributed under the MIT license. However, the repository is archived and no longer maintained, so while it works with current pytest versions, there is no active development or support for future changes.
Use it for:
- Running the same assertion across multiple test inputs and seeing all failures in one test run.
- Converting existing unittest code that uses subTest() to work under pytest without rewriting tests.
- Parameterized testing where you want individual failure reporting for each iteration.
- Testing collections or ranges of values where partial failures should not halt the entire test.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds subTest() support to pytest, allowing unittest-style parameterized test iterations and a subtests fixture for pure pytest tests to report individual failures within a single test function.
Yes, if you need subTest() support in pytest and do not require ongoing maintenance. The plugin is stable and works with modern Python versions (3.9–3.13), has no known vulnerabilities, and low install friction. However, the abandoned status means no fixes or updates for future pytest or Python releases—use it only if you accept that risk or have a fallback plan.
Install
pytest-subtests on PyPI
pip
pip install pytest-subtestsuv
uv add pytest-subtestspoetry
poetry add pytest-subtestsInstalling pytest-subtests
Before you install
Low install friction with only two runtime dependencies (attrs and pytest). However, the repository is archived and marked abandoned as of the latest maintenance status, meaning no active development or support.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
pip install pytest-subtests
# In your test file:
def test_example(subtests):
for i in range(5):
with subtests.test(msg="iteration", i=i):
assert i % 2 == 0
Requires Python 3.9 or later.
Verify before relying
- Whether the abandoned status affects long-term compatibility with future pytest releases.
- Whether there are maintained forks or alternative packages providing similar functionality.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — attrs, pytest |
| Maintenance | abandoned — 298 days since the last release |
| Last repo commit | (repository archived) |
| First released | |
| Downloads | 4,875,378/month — #2,209 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_subtests-0.15.0-py3-none-any.whl
Keywords: test, unittest, pytest
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
pytest-item-dictA pytest plugin that builds hierarchical…
unclear · top 15,000 on PyPI
pytest-loggingA pytest plugin that configures Python logging…
permissive · top 15,000 on PyPI
pytest-assumeA pytest plugin that collects and reports…
permissive · top 15,000 on PyPI
parametrizeProvides a `@parametrize` decorator that works…
permissive · top 15,000 on PyPI
testscenariostestscenarios extends Python's unittest to run…
permissive · top 15,000 on PyPI
softestSoftest extends unittest.TestCase to allow…
unclear · top 15,000 on PyPI
pytest-error-for-skipsA pytest plugin that converts skipped tests…
permissive · top 15,000 on PyPI
unittest-parametrizeAdds parametrization support to unittest…
permissive · top 15,000 on PyPI
kgbkgb intercepts and records function calls in…
permissive · top 5,000 on PyPI