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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b3f29c4b77bf0f9a7f2b02329c6c5e68f0cfb78577cce39fd2d75dede042fcb
|
|
| MD5 |
925a58f0d148335d745b9c20829a9e8b
|
|
| BLAKE2b-256 |
38535b1df1296fe919d36bebb719fa34a49839171028d9e92bfbf2f0b136dc82
|
Provenance
The following attestation bundles were made for nrevah_parametrization-1.0.1.tar.gz:
Publisher:
release.yml on netanelrevah/parametrization
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nrevah_parametrization-1.0.1.tar.gz -
Subject digest:
4b3f29c4b77bf0f9a7f2b02329c6c5e68f0cfb78577cce39fd2d75dede042fcb - Sigstore transparency entry: 1237142922
- Sigstore integration time:
-
Permalink:
netanelrevah/parametrization@97626a951ebef1df22364438f87e85cdb13699dc -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/netanelrevah
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@97626a951ebef1df22364438f87e85cdb13699dc -
Trigger Event:
push
-
Statement type:
File details
Details for the file nrevah_parametrization-1.0.1-py3-none-any.whl.
File metadata
- Download URL: nrevah_parametrization-1.0.1-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f47cbccd6ed62c508bccad55e4969b156e382d90dc9bc4b5d31c6b140a664a62
|
|
| MD5 |
530a8b4ac4e0afb6faffb33ca7ecccb0
|
|
| BLAKE2b-256 |
6f76c3a6edbd725fa5c8384501fcf15e957032754aabca014522d2909f3219f5
|
Provenance
The following attestation bundles were made for nrevah_parametrization-1.0.1-py3-none-any.whl:
Publisher:
release.yml on netanelrevah/parametrization
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nrevah_parametrization-1.0.1-py3-none-any.whl -
Subject digest:
f47cbccd6ed62c508bccad55e4969b156e382d90dc9bc4b5d31c6b140a664a62 - Sigstore transparency entry: 1237142961
- Sigstore integration time:
-
Permalink:
netanelrevah/parametrization@97626a951ebef1df22364438f87e85cdb13699dc -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/netanelrevah
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@97626a951ebef1df22364438f87e85cdb13699dc -
Trigger Event:
push
-
Statement type: