--- id: unittest-parametrize version: "1.8.0" license: MIT license_treatment: permissive maintenance: active --- # unittest-parametrize — Parametrize tests within unittest TestCases. License: permissive · Maintenance: active · Downloads: 247.4K/mo ## 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 above — 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 pip install unittest-parametrize uv add unittest-parametrize poetry add unittest-parametrize ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 247.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags unittest parametrize decorator, parametrized unittest tests, unittest test data driven, multiple test inputs unittest, unittest test case variants, parametrize unittest testcase, unittest parametrized testing, unittest, test-parametrization, django-testing [View on SkillFed](https://skillfed.io/packages/unittest-parametrize) · [View on PyPI](https://pypi.org/project/unittest-parametrize/)