parametrize
Drop-in @pytest.mark.parametrize replacement working with unittest.TestCase
What it is and what it does
Parametrize is a decorator-based test parameterization library that lets you use pytest-style `@parametrize` syntax within `unittest.TestCase` classes. It generates multiple test variants from a single test method, each with different input and expected values, without requiring you to rewrite your existing `setUp`, `tearDown`, or `self.assert*` calls. The decorator works by introspecting the call stack and class scope to dynamically create parameterized test methods at runtime.
The package is designed as a bridge for teams stuck on unittest who want to adopt pytest's parameterization pattern incrementally. It supports stacking multiple `@parametrize` decorators to create Cartesian products of test cases, and integrates with PyCharm's test runner. However, it has strict limitations: all parameterization must use decorators (not applied after definition), other decorators must come before parametrize decorators, and parametrized tests must be run through pytest rather than the standard unittest CLI.
Use it for:
- Gradually migrate a large unittest codebase to pytest-style parameterization without rewriting all test methods at once.
- Run the same test logic with multiple input sets in unittest without manually duplicating test methods or using loops.
- Combine multiple parameter dimensions (e.g., different inputs and expected outputs) using stacked decorators to test all combinations.
- Keep existing unittest infrastructure (setUp, tearDown, self.assert methods) while adopting pytest's cleaner parameterization syntax.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a `@parametrize` decorator that works with `unittest.TestCase` to run parameterized tests, mimicking pytest's `@pytest.mark.parametrize` syntax without requiring a migration away from unittest.
Yes, if you have a large unittest codebase and want to adopt pytest-style parameterization without a full rewrite. The package is stable, has no dependencies, and works well for its narrow purpose. However, the dormant maintenance status and strict decorator-ordering rules mean it's best suited for teams committed to pytest as their long-term test runner. If you're starting fresh or can migrate fully to pytest, use pytest's native parametrize instead.
Install
parametrize on PyPI
pip
pip install parametrizeuv
uv add parametrizepoetry
poetry add parametrizeInstalling parametrize
Before you install
No runtime dependencies and a pure-Python wheel make installation straightforward. The package is dormant (last release May 2021, last commit December 2024) but remains stable for its narrow use case.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions—suitable for most projects.
Quickstart
import unittest
from parametrize import parametrize
class TestSomething(unittest.TestCase):
@parametrize('test_input,expected', [("3+5", 8), ("2+4", 6)])
def test_eval(self, test_input, expected):
self.assertEqual(expected, eval(test_input))
Parametrized tests must be run via pytest CLI (e.g., `pytest test.py`), not `python -m unittest`; decorator assignment must occur at class or module scope, not inside function scope.
Verify before relying
- Whether the package's decorator interoperability with pytest.mark.parametrize is complete enough for gradual migration scenarios.
- How well the package handles edge cases with complex mock.patch stacking or other decorators in real projects.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.6.2,<4.0.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 1,923 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 88,835/month — #13,700 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: parametrize-0.1.1-py3-none-any.whl
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
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
testscenariostestscenarios extends Python's unittest to run…
permissive · top 15,000 on PyPI
unittest-parametrizeAdds parametrization support to unittest…
permissive · top 15,000 on PyPI
pytest-subtestsAdds subTest() support to pytest, allowing…
permissive · top 5,000 on PyPI
pytest-parametrizationProvides decorator-based parametrization for…
permissive · 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
pytest-lazy-fixturesAllows you to reference pytest fixtures…
permissive · top 5,000 on PyPI
pytest-pytestrailA pytest plugin that decorates test functions…
permissive · top 15,000 on PyPI