--- id: parametrize version: "0.1.1" license: MIT license_treatment: permissive maintenance: dormant --- # parametrize — Drop-in @pytest.mark.parametrize replacement working with unittest.TestCase License: permissive · Maintenance: dormant · Downloads: 88.8K/mo ## 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 above — 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 pip install parametrize uv add parametrize poetry add parametrize ## Installing 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_current - Install friction: low - Maintenance: dormant - Downloads: 88.8K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags parametrize unittest tests, pytest parametrize for unittest, unittest test parameterization, parametrized unittest decorator, run multiple test cases unittest, parametrize decorator unittest, unittest-migration, test-parameterization [View on SkillFed](https://skillfed.io/packages/parametrize) · [View on PyPI](https://pypi.org/project/parametrize/)