Skip to main content

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_func or my_module.my_func).
    • Enables:
      • Data-driven tests from config files, databases, or APIs
      • Centralized test data logic
      • Cleaner, more maintainable test code

📦 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.dynamic_parameters.my_params.py
def my_params(config):
    # Example: generate parameters dynamically
    return [
        (1, 2, 3),
        (4, 5, 9),
    ]
  1. Mark your test with @pytest.mark.parametrize_func:
import pytest
from parameterize_functions.dynamic_parameters import my_params

@pytest.mark.parametrize_func("my_params")
def test_add(a, b, expected):
    assert a + b == expected
  • You can also use a fully-qualified function path:

    @pytest.mark.parametrize_func("parameterize_functions.dynamic_parameters.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_dynamic_parameterize-0.1.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_dynamic_parameterize-0.1.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file pytest_dynamic_parameterize-0.1.1.tar.gz.

File metadata

File hashes

Hashes for pytest_dynamic_parameterize-0.1.1.tar.gz
Algorithm Hash digest
SHA256 184d8b65744381dffa02c32cbd14cb186f94555757302d26552b8cd2dcd47eaa
MD5 8f8e851f94ac65dba22ee3c579937b5b
BLAKE2b-256 46ebc70f0409c7f7fc41b0c2f37d1c9f41bbbd14315d9a99ff0e7a717461aa39

See more details on using hashes here.

File details

Details for the file pytest_dynamic_parameterize-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_dynamic_parameterize-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4aaf61d1cf9b885342902ff0f2d6dfd50ea7340a5d56ccd7ff2410b2a0833f29
MD5 aad5931d92a5440327609ce13d878b3c
BLAKE2b-256 7c694db40e249f1ada8844a13f2e974629b60cdcf22185a8b88150e116e92bb7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page