Registry / testing / unittest-parametrize

unittest-parametrize

JSON →
library1.8.0pypypi✓ verified 89d ago

A library to parametrize tests within unittest TestCases using decorators. Current version 1.8.0, released 2024-11-15, with monthly or on-demand releases.

pip install unittest-parametrize
INSTALL
IMPORT
SIG · UNITTEST-PARAMETRI
U
unittest-parametrize
testingpythonv1.8.0
Install
1.6s avg
Import
140ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.8.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.152s · 17.8MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.128s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parametrize
✓ from unittest_parametrize import parametrize
✗ from unittest.parametrize import parametrize
unittest_parametrize is a separate package, not part of stdlib unittest.
parametrize
✓ from unittest_parametrize import parametrize
✗ from parametrize import parametrize
Package name is unittest-parametrize but import uses underscores.

Basic parametrization of a test method with multiple sets of arguments.

from unittest import TestCase from unittest_parametrize import parametrize class MyTest(TestCase): @parametrize( ('a', 'b', 'expected'), [ (1, 2, 3), (4, 5, 9), ], ) def test_add(self, a, b, expected): self.assertEqual(a + b, expected)
Debug
Known issues
gotchaunittest-parametrize only works with unittest.TestCase subclasses, not with pytest or other frameworks. Cannot be used with pytest fixtures.
fix
Use pytest.mark.parametrize if using pytest.
affects: all
gotchaThe decorator must be applied before any other decorators that modify test methods (e.g., @mock.patch). Order matters: parametrize should be the outermost decorator.
fix
Place @parametrize directly above the method definition, with other decorators below it.
affects: all
deprecatedSupport for Python 3.8 has been dropped since version 1.6.0.
fix
Upgrade to Python 3.9+.
affects: >=1.6.0
breakingIn version 1.8.0, the 'ids' parameter changed from accepting a list of strings to also accepting a callable. Code that relied on the old exact list format may break if the callable returns different ordering.
fix
If you use ids as a list, it still works. Only breaking if you passed a callable that was previously ignored; now it is used to generate ids.
affects: 1.8.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'unittest_parametrize'
Package not installed or misspelled import.
fix
Install with 'pip install unittest-parametrize' and import as 'from unittest_parametrize import parametrize'.
TypeError: 'parametrize' object is not callable
Importing the wrong symbol, e.g., from unittest.parametrize import parametrize.
fix
Use correct import: 'from unittest_parametrize import parametrize'.
Upgrade
Version history
1.8.0latest on PyPI · released Sep 9, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
14
Resources
unittest-parametrize — pip install unittest-parametrize · libregistry