{"id":9248,"library":"pytest-parametrization","title":"pytest-parametrization","description":"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.","status":"active","version":"2022.2.1","language":"en","source_language":"en","source_url":"https://github.com/singular-labs/parametrization","tags":["pytest","parametrize","parametrization","testing","plugin"],"install":[{"cmd":"pip install pytest-parametrization","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"This is a pytest plugin and requires pytest to function.","package":"pytest","optional":false},{"reason":"Requires Python versions >=2.6 and not 3.0-3.3.","package":"python","optional":false}],"imports":[{"note":"This plugin provides an alternative decorator 'parametrize' to the built-in 'pytest.mark.parametrize', offering a different syntax for defining test parameters.","wrong":"from pytest import mark.parametrize","symbol":"parametrize","correct":"from parametrization import parametrize"}],"quickstart":{"code":"from parametrization import parametrize\nimport pytest\n\n@parametrize(\n    a=[1, 2],\n    b=[2, 4]\n)\ndef test_addition(a, b):\n    assert a + b == a + b\n\n@parametrize(\n    num=[(1, 'one'), (2, 'two')],\n    ids=['test_one', 'test_two']\n)\ndef test_number_to_word(num, ids):\n    number, word = num\n    if number == 1:\n        assert word == 'one'\n    elif number == 2:\n        assert word == 'two'\n\n# To run: pytest -v your_test_file.py","lang":"python","description":"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."},"warnings":[{"fix":"Ensure you explicitly import `parametrize` from `parametrization` and understand its distinct usage pattern.","message":"This 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"When 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"There'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`.","severity":"gotcha","affected_versions":"Python 3.12+ (Pytest 8.0+)"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Add `from parametrization import parametrize` at the top of your test file.","cause":"The `parametrize` decorator from the plugin was used without the correct import statement.","error":"NameError: name 'parametrize' is not defined"},{"fix":"Double-check the syntax of your `@parametrize` decorator. Ensure parameter values are correctly passed as lists for each argument name, e.g., `@parametrize(arg_name=[value1, value2])`.","cause":"This error can occur if you mistakenly try to call a list of parameters as if it were a function, or misconfigure the `parametrize` decorator.","error":"TypeError: 'list' object is not callable"},{"fix":"Run `pytest -v` or `pytest --pdb` to get verbose output or drop into a debugger upon failure. The detailed test IDs from `pytest-parametrization` should help identify which specific parameter set caused the failure.","cause":"A test assertion failed for one or more parametrized test cases.","error":"AssertionError: assert X == Y (where X and Y are values)"}]}