skillfed

parametrize

Drop-in @pytest.mark.parametrize replacement working with unittest.TestCase

parametrize v0.1.1 88.8K downloads/30d#13,700 on PyPI18
Permissive license MIT DORMANT released

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 parametrize

uv

uv add parametrize

poetry

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

Development Status :: 3 - AlphaFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTopic :: Software Development :: LibrariesTopic :: Software Development :: TestingTopic :: Software Development :: Testing :: UnitTyping :: Typed

Tags

parametrize unittest testspytest parametrize for unittestunittest test parameterizationparametrized unittest decoratorrun multiple test cases unittestparametrize decorator unittest
unittest-migrationtest-parameterization

More Libraries packages