Pytest decorator for parametrizing tests with default iterables.
Project description
Pytest decorator for parametrizing tests with default iterables, providing alternative syntax for pytest.mark.parametrize.
Usage
Decorate tests with iterable default values. Other fixtures can still be used as normal.
functions
from parametrized import parametrized
@parametrized
def test(..., name=values):
"""test single parametrized arg with each value"""
@parametrized.zip
def test(name=values, name1=values1, ...):
"""test parametrized args with zipped values"""
@parametrized.product
def test(name=values, name1=values1, ...):
"""test parametrized args with cartesian product of values"""
Zip before and after example:
@pytest.mark.parametrize("test_input,expected", [
("3+5", 8),
("2+4", 6),
("6*9", 42),
])
def test_eval(test_input, expected):
assert eval(test_input) == expected
@parametrized.zip
def test_eval(test_input=["3+5", "2+4", "6*9"], expected=[8, 6, 42]):
assert eval(test_input) == expected
Product before and after example:
@pytest.mark.parametrize("x", [0, 1])
@pytest.mark.parametrize("y", [2, 3])
def test_foo(x, y):
pass
@parametrized.product
def test_foo(x=[0, 1], y=[2, 3]):
pass
pytest.param is supported for single values or .product.
fixtures
Parametrized fixtures which simply return their param.
fixture_name = parametrized.fixture(*params, **kwargs)
Before and after example:
@pytest.fixture(params=[0, 1], ids=["spam", "ham"])
def a(request):
return request.param
a = parametrized.fixture(0, 1, ids=["spam", "ham"])
Installation
% pip install pytest-parametrized
Tests
100% branch coverage.
% pytest [--cov]
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
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 pytest_parametrized-1.7.tar.gz.
File metadata
- Download URL: pytest_parametrized-1.7.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ec50eb164dae2ad3a0595ec197ff8bc1ce741342991f0016ba7daa6a861361b
|
|
| MD5 |
3033c5e0559832f8767a01e27195d505
|
|
| BLAKE2b-256 |
44ae8ed9bd7dee749610f4e1c52f1bc28f1dfc873f41fc54fcaf509e07829237
|
Provenance
The following attestation bundles were made for pytest_parametrized-1.7.tar.gz:
Publisher:
release.yml on coady/pytest-parametrized
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_parametrized-1.7.tar.gz -
Subject digest:
3ec50eb164dae2ad3a0595ec197ff8bc1ce741342991f0016ba7daa6a861361b - Sigstore transparency entry: 157254493
- Sigstore integration time:
-
Permalink:
coady/pytest-parametrized@11a16040b11af753610d0ab8b6ccc0417818b16e -
Branch / Tag:
refs/tags/v1.7 - Owner: https://github.com/coady
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@11a16040b11af753610d0ab8b6ccc0417818b16e -
Trigger Event:
push
-
Statement type:
File details
Details for the file pytest_parametrized-1.7-py3-none-any.whl.
File metadata
- Download URL: pytest_parametrized-1.7-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7da6948c0ccb6798924f600b01c4c19064d46fd2bd49b5406c2d9aa7303d05e
|
|
| MD5 |
6088877197fdb191099f5f2bcb6d3158
|
|
| BLAKE2b-256 |
926651fdf9cb516783cfa9363b587fd9a99f86726bd5606baa6c9adf0fa4b0d2
|
Provenance
The following attestation bundles were made for pytest_parametrized-1.7-py3-none-any.whl:
Publisher:
release.yml on coady/pytest-parametrized
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_parametrized-1.7-py3-none-any.whl -
Subject digest:
a7da6948c0ccb6798924f600b01c4c19064d46fd2bd49b5406c2d9aa7303d05e - Sigstore transparency entry: 157254494
- Sigstore integration time:
-
Permalink:
coady/pytest-parametrized@11a16040b11af753610d0ab8b6ccc0417818b16e -
Branch / Tag:
refs/tags/v1.7 - Owner: https://github.com/coady
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@11a16040b11af753610d0ab8b6ccc0417818b16e -
Trigger Event:
push
-
Statement type: