unittest-parametrize
Parametrize tests within unittest TestCases.
What it is and what it does
unittest-parametrize is a decorator-based library that brings pytest-style parametrization to the standard unittest framework. It lets you write a single test method and run it multiple times with different input values, generating separate named test cases for each parameter set. The decorator works by modifying the test class at definition time using Python's __init_subclass__ hook, creating individual wrapped copies of your test method with unique names—so the parametrization works with any test runner (unittest, Django's test runner, pytest, etc.) and supports both synchronous and asynchronous test methods.
The library mirrors pytest's @pytest.mark.parametrize API closely, accepting argument names as a comma-separated string or sequence, a list of parameter tuples or param objects, and optional custom test ID suffixes. You inherit from ParametrizedTestCase in your test class and apply @parametrize to any test methods you want to parametrize. It handles single parameters without tuple wrapping, multiple parameters, and custom naming via param IDs, a sequence of ID strings, or a callable.
Use it for:
- Test the same logic across a range of inputs (e.g., testing a square function with multiple values) without duplicating test code.
- Verify edge cases and boundary conditions by running a single test method with different parameter sets.
- Generate readable test reports with custom test names via param IDs, making failures easier to trace.
- Integrate parametrized tests into Django projects by mixing ParametrizedTestCase into your project's base test case classes.
- Run parametrized tests across different test runners (unittest, pytest, Django) without rewriting test code.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds parametrization support to unittest TestCases, allowing you to run the same test method with multiple sets of inputs without writing duplicate test code.
Yes. unittest-parametrize is a lightweight, actively maintained tool that solves a genuine pain point in unittest—the lack of native parametrization. It has no security vulnerabilities, minimal dependencies, and works across modern Python versions. If you use unittest or Django's test runner and want to avoid duplicating test code for multiple inputs, it's a straightforward win.
Install
unittest-parametrize on PyPI
pip
pip install unittest-parametrizeuv
uv add unittest-parametrizepoetry
poetry add unittest-parametrizeInstalling unittest-parametrize
Before you install
Installs with no dependencies beyond typing-extensions. Actively maintained with a recent release and no known vulnerabilities.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects.
Quickstart
from unittest_parametrize import ParametrizedTestCase, parametrize
class MyTests(ParametrizedTestCase):
@parametrize("x,expected", [(1, 1), (2, 4)])
def test_square(self, x, expected):
self.assertEqual(x**2, expected)
Requires Python 3.9 or later.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing-extensions |
| Maintenance | actively maintained — 339 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 247,393/month — #8,693 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: unittest_parametrize-1.8.0-py3-none-any.whl
Keywords: unittest
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
parametrizeProvides a `@parametrize` decorator that works…
permissive · top 15,000 on PyPI
pytest-parametrizationProvides decorator-based parametrization for…
permissive · top 15,000 on PyPI
parameterizedParameterized testing decorator that works with…
permissive · top 5,000 on PyPI
pytest-casespytest-cases lets you separate test case data…
permissive · top 5,000 on PyPI
pytest-subtestsAdds subTest() support to pytest, allowing…
permissive · top 5,000 on PyPI
softestSoftest extends unittest.TestCase to allow…
unclear · top 15,000 on PyPI
pytest-lazy-fixtureAllows you to use pytest fixtures directly as…
permissive · top 15,000 on PyPI
ddtddt multiplies a single test case across…
permissive · top 5,000 on PyPI
nose2nose2 is a test runner that extends Python's…
permissive · top 15,000 on PyPI
concurrencytestRuns unittest test suites concurrently across…
copyleft · top 15,000 on PyPI