freshcrate
Skin:/
Home > Frameworks > pytest-subtests

pytest-subtests

unittest subTest() support and subtests fixture

Why this rank:Strong adoptionRelease freshnessHealthy release cadence

Description

=============== pytest-subtests =============== unittest ``subTest()`` support and ``subtests`` fixture. .. image:: https://img.shields.io/pypi/v/pytest-subtests.svg :target: https://pypi.org/project/pytest-subtests :alt: PyPI version .. image:: https://img.shields.io/conda/vn/conda-forge/pytest-subtests.svg :target: https://anaconda.org/conda-forge/pytest-subtests .. image:: https://img.shields.io/pypi/pyversions/pytest-subtests.svg :target: https://pypi.org/project/pytest-subtests :alt: Python versions .. image:: https://github.com/pytest-dev/pytest-subtests/workflows/test/badge.svg :target: https://github.com/pytest-dev/pytest-subtests/actions .. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/ambv/black ---- This `pytest`_ plugin was generated with `Cookiecutter`_ along with `@hackebrot`_'s `cookiecutter-pytest-plugin`_ template. Features -------- * Adds support for `TestCase.subTest <https://docs.python.org/3/library/unittest.html#distinguishing-test-iterations-using-subtests>`__. * New ``subtests`` fixture, providing similar functionality for pure pytest tests. Installation ------------ You can install ``pytest-subtests`` via `pip`_ from `PyPI`_:: $ pip install pytest-subtests Usage ----- unittest subTest() example ^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: python import unittest class T(unittest.TestCase): def test_foo(self): for i in range(5): with self.subTest("custom message", i=i): self.assertEqual(i % 2, 0) if __name__ == "__main__": unittest.main() **Output** .. code-block:: Îģ pytest .tmp\test-unit-subtest.py ======================== test session starts ======================== ... collected 1 item .tmp\test-unit-subtest.py FF. [100%] ============================= FAILURES ============================== _________________ T.test_foo [custom message] (i=1) _________________ self = <test-unit-subtest.T testMethod=test_foo> def test_foo(self): for i in range(5): with self.subTest('custom message', i=i): > self.assertEqual(i % 2, 0) E AssertionError: 1 != 0 .tmp\test-unit-subtest.py:9: AssertionError _________________ T.test_foo [custom message] (i=3) _________________ self = <test-unit-subtest.T testMethod=test_foo> def test_foo(self): for i in range(5): with self.subTest('custom message', i=i): > self.assertEqual(i % 2, 0) E AssertionError: 1 != 0 .tmp\test-unit-subtest.py:9: AssertionError ================ 2 failed, 1 passed in 0.07 seconds ================= ``subtests`` fixture example ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: python def test(subtests): for i in range(5): with subtests.test(msg="custom message", i=i): assert i % 2 == 0 **Output** .. code-block:: Îģ pytest .tmp\test-subtest.py ======================== test session starts ======================== ... collected 1 item .tmp\test-subtest.py .F.F.. [100%] ============================= FAILURES ============================== ____________________ test [custom message] (i=1) ____________________ def test(subtests): for i in range(5): with subtests.test(msg='custom message', i=i): > assert i % 2 == 0 E assert (1 % 2) == 0 .tmp\test-subtest.py:4: AssertionError ____________________ test [custom message] (i=3) ____________________ def test(subtests): for i in range(5): with subtests.test(msg='custom message', i=i): > assert i % 2 == 0 E assert (3 % 2) == 0 .tmp\test-subtest.py:4: AssertionError ================ 2 failed, 1 passed in 0.07 seconds ================= Contributing ------------ Contributions are very welcome. Tests can be run with `tox`_. License ------- Distributed under the terms of the `MIT`_ license, "pytest-subtests" is free and open source software Issues ------ If you encounter any problems, please `file an issue`_ along with a detailed description. .. _`Cookiecutter`: https://github.com/audreyr/cookiecutter .. _`@hackebrot`: https://github.com/hackebrot .. _`MIT`: http://opensource.org/licenses/MIT .. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin .. _`file an issue`: https://github.com/pytest-dev/pytest-subtests/issues .. _`pytest`: https://github.com/pytest-dev/pytest .. _`tox`: https://tox.readthedocs.io/en/latest/ .. _`pip`: https://pypi.org/project/pip/ .. _`PyPI`: https://pypi.org/project/pytest-subtests/

Release History

VersionChangesUrgencyDate
0.15.0Imported from PyPI (0.15.0)Low4/21/2026
v0.15.0Release v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.15.0Latest release: v0.15.0Low10/20/2025
v0.14.2Release v0.14.2Low6/13/2025
v0.14.1Release v0.14.1Low12/10/2024
v0.14.0See the [CHANGELOG](https://github.com/pytest-dev/pytest-subtests/blob/main/CHANGELOG.rst).Low12/7/2024
v0.13.1Release v0.13.1Low7/17/2024
v0.13.0## What's Changed * Fix compatibility with pytest 8.1 by @nicoddemus in https://github.com/pytest-dev/pytest-subtests/pull/126 * [pre-commit.ci] pre-commit autoupdate by @pre-commit-ci in https://github.com/pytest-dev/pytest-subtests/pull/127 * [pre-commit.ci] pre-commit autoupdate by @pre-commit-ci in https://github.com/pytest-dev/pytest-subtests/pull/128 * [pre-commit.ci] pre-commit autoupdate by @pre-commit-ci in https://github.com/pytest-dev/pytest-subtests/pull/129 * [pre-commit.ci] pre-comLow7/7/2024

Dependencies & License Audit

Loading dependencies...

Similar Packages

pyhamcrestHamcrest framework for matcher objects2.1.0
pyfakefsImplements a fake file system that mocks the Python file system modules.6.2.0
pytest-rerunfailurespytest plugin to re-run tests to eliminate flaky failuresmaster@2026-06-03
pytest-randomlyPytest plugin to randomly order tests and control random.seed.main@2026-06-01
time-machineTravel through time in your tests.main@2026-06-01

More in Frameworks

langchainThe agent engineering platform
deer-flowAn open-source long-horizon SuperAgent harness that researches, codes, and creates. With the help of sandboxes, memories, tools, skill, subagents and message gateway, it handles different levels of ta
tqdmFast, Extensible Progress Meter
simBuild, deploy, and orchestrate AI agents. Sim is the central intelligence layer for your AI workforce.