A Python package for managing pytest plugins.
Project description
pytest-dynamic-parameterize
A powerful pytest plugin for Python projects, enabling dynamic test parameterization using functions.
Easily generate test parameters at runtime from any function—supporting advanced, data-driven, or config-based testing workflows.
🚀 Features
- ✅ Dynamic Parameterization: Generate test parameters dynamically by referencing a function.
- Use the
@pytest.mark.parametrize_func("function_name")marker on your test. - Supports both local and fully-qualified function names (e.g.,
my_funcormy_module.my_func). - Supports multiple
@pytest.mark.parametrize_funcmarkers on a single test for advanced parameterization. - Pass keyword arguments to your parameter function via the marker:
@pytest.mark.parametrize_func("my_params", some_param="some_value"). - Enables:
- Data-driven tests from config files, databases, or APIs
- Centralized test data logic
- Cleaner, more maintainable test code
- Use the
📦 Installation
pip install pytest-dynamic-parameterize
🔧 Usage
- Define a parameter function (must accept a
configargument and return a list of tuples or values):
# parameterize_functions.parametrize_functions.my_params.py
def my_params(config, some_param=None) -> list[tuple]:
if some_param == "special":
return [(10, 20, 30)]
return [
(1, 2, 3),
(4, 5, 9),
]
- Mark your test with one or more
@pytest.mark.parametrize_funcdecorators:
import pytest
from tests.parameterize_functions.my_params import my_params
@pytest.mark.parametrize_func("my_params")
def test_add(a, b, expected):
assert a + b == expected
-
Pass arguments to your parameter function:
import pytest from tests.parameterize_functions.my_params import my_params @pytest.mark.parametrize_func("my_params", some_param="special") def test_add_special(a, b, expected): assert a + b == expected
-
Use multiple parametrize_func markers for advanced parameterization:
import pytest from tests.parameterize_functions.my_params import my_params @pytest.mark.parametrize_func("my_params", some_param="special") @pytest.mark.parametrize_func("my_params") def test_add_multi(a1, b1, expected1, a2, b2, expected2): assert a1 + b1 == expected1 assert a2 + b2 == expected2
-
You can also use a fully-qualified function path:
import pytest @pytest.mark.parametrize_func("parameterize_functions.parametrize_functions.my_params") def test_add(a, b, expected): ...
-
The function can be imported or defined in the same module.
-
The function should return a list of argument tuples matching the test signature.
🤝 Contributing
If you have improvements, ideas, or bugfixes:
- Fork the repo
- Create a new branch
- Submit a pull request
I welcome additions that promote clean, productive, and maintainable development.
🙏 Thanks
Thanks for exploring this repository!
Happy testing!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_dynamic_parameterize-0.1.13.tar.gz.
File metadata
- Download URL: pytest_dynamic_parameterize-0.1.13.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
593d385b416a16549339700e418fb10f3eb006d61cf988b58a2846d8c65d5352
|
|
| MD5 |
91dd7e367eecdb1d3430b7deda998313
|
|
| BLAKE2b-256 |
81bd998715f8d266151c54a53e30c0653a36fcbfbbffee0d95c157da360d7335
|
File details
Details for the file pytest_dynamic_parameterize-0.1.13-py3-none-any.whl.
File metadata
- Download URL: pytest_dynamic_parameterize-0.1.13-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a09685a804a55ed965996251e810d91edc79301afa3f9b1431b576e64a0525e
|
|
| MD5 |
2db861e96b7212bffbf57bef13c35b4b
|
|
| BLAKE2b-256 |
74502210a9b1f2d80f6d4b95e1663dee67d755ce78f198965c8ed0b2a71d299c
|