Skip to main content

PyPI version Python Development Status Maintenance PyPI License


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_func or my_module.my_func).
    • Supports multiple @pytest.mark.parametrize_func markers 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
    • For skipped tests, for empty parameter sets, you can return NOT_SET_PARAMETERS from your parameter function to indicate no parameters should be set.

📦 Installation

pip install pytest-dynamic-parameterize

🔧 Usage

  1. Define a parameter function (must accept a config argument 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),
    ]
  1. Mark your test with one or more @pytest.mark.parametrize_func decorators:
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!

Release files for pytest-dynamic-parameterize 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-dynamic-parameterize 1.2.0
File Size Uploaded
pytest_dynamic_parameterize-1.2.0.tar.gz 5.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-dynamic-parameterize 1.2.0
File Interpreter ABI Platform
pytest_dynamic_parameterize-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.3 kB

Release files / pytest_dynamic_parameterize-1.2.0.tar.gz

Download URL pytest_dynamic_parameterize-1.2.0.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
187beba1d7a531257f9a8fe081fc28f3c946a0932a9e34611721414824a4d2e5
BLAKE2b-256 checksum
How to use checksums
8b0ee38c4e492d9ec01b367aa8568c01eddc6176ce4121e720da19bdea913bd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / pytest_dynamic_parameterize-1.2.0-py3-none-any.whl

Download URL pytest_dynamic_parameterize-1.2.0-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
343b25d6260756b4505bb5740ffaece553ec956373dfeeabec04bec85ab43317
BLAKE2b-256 checksum
How to use checksums
e9e123fc7dad0f1e1d885a19fecf5c89263c5b9fca277b66a2298eee67317ac5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page