skillfed

pytest-subtests

unittest subTest() support and subtests fixture

pytest-subtests v0.15.0 4.9M downloads/30d#2,209 on PyPI256
Permissive license MIT Abandoned released

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-subtests

uv

uv add pytest-subtests

poetry

poetry add pytest-subtests

Installing 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

Development Status :: 4 - BetaFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTopic :: Software Development :: TestingTyping :: Typed

Tags

pytest subtest supportunittest subTest pytestparameterized test iterationspytest subtests fixturetest iteration reportingnested test failures
unittest-compatparameterized-testing

More Testing packages