Registry / testing / pytest-parametrization

pytest-parametrization

JSON →
library2022.2.1pypypi✓ verified 85d ago

pytest-parametrization is a Pytest plugin that aims to provide a simpler and more explicit way to parametrize test functions compared to the built-in `@pytest.mark.parametrize` decorator. It allows for clearer definition of test cases by separating parameter names from their values. The current version is 2022.2.1, with an irregular release cadence; the last PyPI update was in May 2022.

pip install pytest-parametrization
INSTALL
IMPORT
SIG · PYTEST-PARAMETRIZA
P
pytest-parametrization
testingpythonv2022.2.1
Install
3.6s avg
Import
Disk
30MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2022.2.1 · 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.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 32.2MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.6s · import 0.000s · 33MB
30MB installed
● package 30MB
Code
Verified usage

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

Parametrization
from parametrization import Parametrization
from parametrization import parametrize

This example demonstrates how to use the `@parametrize` decorator from the `pytest-parametrization` plugin. It allows defining parameters using keyword arguments, where the values for each parameter are lists. The plugin also supports custom test IDs.

from parametrization import parametrize import pytest @parametrize( a=[1, 2], b=[2, 4] ) def test_addition(a, b): assert a + b == a + b @parametrize( num=[(1, 'one'), (2, 'two')], ids=['test_one', 'test_two'] ) def test_number_to_word(num, ids): number, word = num if number == 1: assert word == 'one' elif number == 2: assert word == 'two' # To run: pytest -v your_test_file.py
Debug
Known issues
gotchaThis library provides an alternative syntax (`from parametrization import parametrize`) to the standard Pytest parametrization (`@pytest.mark.parametrize`). Users should be aware they are using a plugin with its own conventions, not the built-in decorator directly.
fix
Ensure you explicitly import `parametrize` from `parametrization` and understand its distinct usage pattern.
affects: All versions
gotchaWhen passing mutable objects (like lists or dictionaries) as parameters, `pytest` (and by extension this plugin) passes them by reference, not by copy. Modifying a mutable parameter in one test case will affect subsequent test cases that receive the same parameter instance.
fix
If mutable parameters need to be unique per test, make a deep copy within the test function or use fixtures for setup that return new instances.
affects: All versions
gotchaThere's a known `pytest` core issue with `@pytest.mark.parametrize` causing reference leaks on newer Python versions (3.12+), preventing reliable object cleanup by the GC during interpreter shutdown. While this is a `pytest` core problem, it impacts any test using parametrization, including those with `pytest-parametrization`.
fix
Keep `pytest` and Python updated. If encountering significant issues with leak reporting in specific scenarios (e.g., C++ bindings), monitor `pytest`'s issue tracker for updates on Issue #11773.
affects: Python 3.12+ (Pytest 8.0+)
Upgrade
Version history
2022.2.1latest on PyPI · released May 22, 2022
Audit
Dependencies
pytestrequiredThis is a pytest plugin and requires pytest to function.
pythonrequiredRequires Python versions >=2.6 and not 3.0-3.3.
Agent activity
4 hits · last 30 days
node
4
Resources
pytest-parametrization — pip install pytest-parametrization · libregistry