Skip to main content

Nice Parametrize

Usage example:

from nice_parametrize import parametrize

@parametrize(["a", "b", "result"], {
    "equal": [1, 1, True],
    "unequal": [1, 2, False],
})
def my_test(a, b, result):
    assert (a == b) is result

A small Python snippet that makes pytest.mark.parametrize a little nicer to use.

pytest.mark.parametrize has a nice feature called ids that allows you to name your argument lists. This is very useful for stating the intention of the tested case. But the problem is that the names are given in a separate parameter, ids, so it is not easy to see at a glance which arguments match which case:

import pytest

@pytest.mark.parametrize(["a", "b", "result"], [
    [1, 1, True], 
    [1, 2, False]], 
ids=["equal", "unequal"])
def my_test(a, b, result):
    assert (a == b) is result

This might get very cumbersome with a long parameter list and a lot of cases. So instead, nice_parametrize allows you to pass in a dict that maps between the ID of the argument list to the list itself. This way it is clear which case match which arguments, and it is easier to understand and debug your test.

Also supports additional keyword arguments to be passed to the underlying pytest.mark.parametrize.

Metadata

Release files for pytest-nice-parametrize 1.0.1

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-nice-parametrize 1.0.1
File Size Uploaded Provenance Actions
pytest-nice-parametrize-1.0.1.tar.gz 2.3 kB Without provenance Details for pytest-nice-parametrize-1.0.1.tar.gz

Release files / pytest-nice-parametrize-1.0.1.tar.gz

Download URL pytest-nice-parametrize-1.0.1.tar.gz
Size 2.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cf1e874d83238bb9af1c4140c9f59caad6eee0ab0c2f4cb77b098989263c49d7
BLAKE2b-256 checksum
How to use checksums
c0d8bafbfc69e86faed3041fe87b0eefb137619d5ec2d4af3dc63fa61e40a4f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.1

Security for pytest-nice-parametrize 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file No provenance

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