Pytest-parametrize-suite

Latest version: v23.1.2

Safety actively analyzes 623343 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

23.1.2

What's New

Now you can stack `suite` markers on your test and the tests will generate a cross-product of the cominations, just like the `parametrize` marker.

Example

The following test:

python
pytest.mark.suite(
case1=dict(arg1="cross1"),
case2=dict(arg1="cross2"),
)
pytest.mark.suite(
case3=dict(arg2="product1"),
case4=dict(arg2="product2"),
)
def test_suite_matrix(arg1, arg2):
Given
combination = arg1 + arg2
When
possible_combinations.remove(combination)
Then
assert combination not in possible_combinations


possible_combinations = {
"cross1product1",
"cross1product2",
"cross2product1",
"cross2product2",
}



Generates the follwing output:


poetry run coverage run --rcfile=.coveragerc -m pytest . -v
=========================== test session starts ===========================
...
tests/test_plugin.py::test_suite_matrix[case3-case1] PASSED [ 61%]
tests/test_plugin.py::test_suite_matrix[case3-case2] PASSED [ 69%]
tests/test_plugin.py::test_suite_matrix[case4-case1] PASSED [ 76%]
tests/test_plugin.py::test_suite_matrix[case4-case2] PASSED [ 84%]
...

23.1.0

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.