skillfed

unittest-parametrize

Parametrize tests within unittest TestCases.

unittest-parametrize v1.8.0 247.4K downloads/30d#8,693 on PyPI77
Permissive license MIT Active released

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

uv

uv add unittest-parametrize

poetry

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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersNatural Language :: EnglishProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Typing :: Typed

Tags

unittest parametrize decoratorparametrized unittest testsunittest test data drivenmultiple test inputs unittestunittest test case variantsparametrize unittest testcaseunittest parametrized testing
unittesttest-parametrizationdjango-testing

More Testing packages