Skip to content

11 - pytest-cases

The core idea behind pytest-cases is to separate test code from test cases. One of its cool features is the possibility to use fixtures inside parametrize. Additionally, it enables familiar syntax for parametrizing fixtures.


The output looks like this:


Read more
The code
from pytest_cases import fixture, parametrize

def fixture1() -> str:
    return "foo"

@parametrize("value", ["bar", "baz"])
def fixture2(value: str) -> str:
    return value

@parametrize("value", [fixture1, fixture2])
def test_just_a_dummy_example(value: str) -> None:
    assert value in ("foo", "bar", "baz")