pytest
From Parametrize Tests
Go to text →
Parametrize tests
Single argument
@pytest.mark.parametrize("color", ["red", "blue", "green"], id=str)
Multiple arguments
@pytest.mark.parametrize("height,width", [(20, 30), (40, 10)], id=str)
Custom human readable ids
@pytest.mark.parametrize(
"height,width",
[
(10, 5),
(400, 200)
],
ids=[
'small size',
'big size'
]
)
From Parametrize Fixtures
Go to text →
Parametrizing fixtures
Indirectly on test cases
@pytest.mark.parametrize("fixture_name", ["value1", "value2"], indirect=True)
Directly in fixtures via request.param
@pytest.fixture(params=["smtp.gmail.com", "mail.python.org"])
def some_fixture_value(request):
# use request.param
From Use Fixtures
Go to text →
Use fixtures
Without having them as argument
@pytest.mark.usefixtures("cleandir")
Children