Skip to main content

image image image

GitHub Workflow Status pre-commit image

pytest-parametrize

pytest decorator for parametrizing test cases in a dict-way. It is an alternative for the pytest.mark.parametrize.

Usage

Decorate test function with test cases defined as a dictionary.

Example:

Simple

import pytest
from pytest_parametrize import parametrize

@parametrize(
    {
        "test-case-1": {"a": 1, "b": 2, "c": 3},
        "test-case-2": {"a": 2, "b": 3, "c": 5},
        "test-case-3": [
            {"a": 3, "b": 5, "c": 8},
            {"a": 5, "b": 8, "c": 13},
            {"a": 8, "b": 13, "c": 21},
            {"a": 0, "b": 0, "c": 1, "marks": pytest.mark.xfail},
        ],
    },
)
def test_something(a, b, c):
    assert a + b == c

Or more complex one:

from pytest_parametrize import parametrize

@parametrize(
    {
        "a=1": {"a": 1},
        "a=2": {"a": 2},
    }
)
@parametrize(
    {
        "b=1": {"b": 1},
        "b=2": {"b": 2},
    }
)
def test_parametrize__when_complex_structure(a: int, b: int):
    assert a * b > 0

Description

Decorator takes dict, which:

  • keys define names of the test cases, and
  • values define named arguments in dict manner (or list of such dicts), which are passed to the decorated test function.

Installation

pip

pip install pytest-parametrize

poetry

poetry add pytest-parametrize

Collaboration

Test & coverage

pytest -vvv tests --cov=pytest_parametrize

Release files for pytest-parametrize 1.6.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-parametrize 1.6.0
File Size Uploaded
pytest_parametrize-1.6.0.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-parametrize 1.6.0
File Interpreter ABI Platform
pytest_parametrize-1.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.3 kB

Release files / pytest_parametrize-1.6.0.tar.gz

Download URL pytest_parametrize-1.6.0.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d647c415bd5be28130499f529b6424cf49fd6b5bf2581ffed94300abc01f0c2a
BLAKE2b-256 checksum
How to use checksums
85b31eecbc7cd2fd54f18e9b27e0b5bacac22ed69af125b31c5144efcfe12a39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.3 CPython/3.14.3 Linux/6.17.0-1008-azure

Release files / pytest_parametrize-1.6.0-py3-none-any.whl

Download URL pytest_parametrize-1.6.0-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
775d7367369840eaa0358c03e869464e0627b39dd94750d242e880e6f081dab3
BLAKE2b-256 checksum
How to use checksums
95e30722a455d5e3ba8d9fa29f2e314cf3feffa060c4e78170f5576c9915624b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.3 CPython/3.14.3 Linux/6.17.0-1008-azure

Release history Release notifications | RSS feed

This release

1.6.0 This release

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.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