Skip to main content

nrevah-parametrization: Simpler PyTest parametrization

Project description

nrevah-parametrization

Simpler PyTest parametrization

How to install

pip install nrevah-parametrization

How to use

Parametrization (or the short alias p) provides a decorator-based API for parametrizing pytest tests.

Explicit parameters

from parametrization import p

@p.parameters("actual", "expected")
@p.case(name="some_case_0", actual=1, expected=2)
@p.case("some_case_1", actual=1, expected=2)
@p.case("some_case_2", 1, expected=1)
@p.case("some_case_3", 2, 2)
@p.case("some_case_4", 3, 3)
def test_somthing(actual, expected):
    assert actual == expected

Auto-detect parameters

from parametrization import p

@p.autodetect_parameters()
@p.case(name="some_case_0", actual=1, expected=2)
@p.case("some_case_1", actual=1, expected=2)
@p.case("some_case_2", actual=1, expected=1)
def test_somthing(actual, expected):
    assert actual == expected

Auto-detect parameters with default parameter

from parametrization import p

@p.autodetect_parameters()
@p.default_parameters(expected=None)
@p.case(name="some_case_0", actual=1, expected=2)
@p.case("some_case_1", actual=1, expected=2)
@p.case("some_case_2", actual=1, expected=1)
@p.case("some_case_2", actual=1)
def test_somthing(actual, expected):
    assert actual == expected

Generate name based on arguments

from parametrization import p

@p.name_factory(lambda actual, expected: f"{actual}=={expected}")
@p.case(actual=1, expected=1)
@p.case(actual=2, expected=2)
@p.case("special-name", actual=3, expected=3)
def test_somthing(actual, expected):
    assert actual == expected

As can be seen from the example, you can also give explicit name for a case even if you are using name factory.

The long form Parametrization is also available for those who prefer it:

from parametrization import Parametrization

@Parametrization.autodetect_parameters()
@Parametrization.case(name="some_case_0", actual=1, expected=2)
def test_somthing(actual, expected):
    assert actual == expected

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

nrevah_parametrization-1.0.1.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

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

nrevah_parametrization-1.0.1-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file nrevah_parametrization-1.0.1.tar.gz.

File metadata

  • Download URL: nrevah_parametrization-1.0.1.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nrevah_parametrization-1.0.1.tar.gz
Algorithm Hash digest
SHA256 4b3f29c4b77bf0f9a7f2b02329c6c5e68f0cfb78577cce39fd2d75dede042fcb
MD5 925a58f0d148335d745b9c20829a9e8b
BLAKE2b-256 38535b1df1296fe919d36bebb719fa34a49839171028d9e92bfbf2f0b136dc82

See more details on using hashes here.

Provenance

The following attestation bundles were made for nrevah_parametrization-1.0.1.tar.gz:

Publisher: release.yml on netanelrevah/parametrization

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nrevah_parametrization-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for nrevah_parametrization-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f47cbccd6ed62c508bccad55e4969b156e382d90dc9bc4b5d31c6b140a664a62
MD5 530a8b4ac4e0afb6faffb33ca7ecccb0
BLAKE2b-256 6f76c3a6edbd725fa5c8384501fcf15e957032754aabca014522d2909f3219f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for nrevah_parametrization-1.0.1-py3-none-any.whl:

Publisher: release.yml on netanelrevah/parametrization

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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