pytest-plugin: crosszip_parametrize
pytest_configure(config)
Register the crosszip_parametrize marker with pytest.
This pytest hook registers the crosszip_parametrize marker with pytest. The marker
is used to parametrize tests with the Cartesian product of parameter values.
Source code in src/crosszip/plugin.py
pytest_generate_tests(metafunc)
Generate parametrized tests using the cross-product of parameter values.
This pytest hook parametrizes tests based on the crosszip_parametrize marker.
It extracts parameter names and their corresponding lists of values, computes their
Cartesian product, and parametrizes the test function accordingly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metafunc
|
Metafunc
|
The test function's metadata provided by pytest. |
required |
Example
import math
import crosszip
import pytest
@pytest.mark.crosszip_parametrize(
"base",
[2, 10],
"exponent",
[-1, 0, 1],
)
def test_power_function(base, exponent):
result = math.pow(base, exponent)
assert result == base**exponent
@pytest.mark.crosszip_parametrize()
def test_example():
pass
# Error: Parameter names and values must be provided.
@pytest.mark.crosszip_parametrize(
"x",
1,
"y",
[3, 4],
)
def test_example(x, y):
pass
# Error: All parameter values must be non-empty sequences.