Complete worked example
python
import pytest
def serialize(fields, delimiter):
return delimiter.join(fields)
@pytest.fixture(params=[",", ";"], ids=["comma", "semicolon"])
def delimiter(request):
return request.param
def test_two_fields(delimiter):
expected = {",": "a,b", ";": "a;b"}[delimiter]
assert serialize(["a", "b"], delimiter) == expected- Reasoning
- The fixture declares params and returns request.param. Each requesting test receives one delimiter at a time. The worked test checks a two-field serialization against a literal expected value for that delimiter. IDs make failures readable without inspecting a numeric fixture index. If a test also has three data parameters, two delimiter configurations can produce six items. This Cartesian expansion is deliberate, not free coverage. Keep cases orthogonal and inspect --collect-only before introducing a much larger matrix into CI.