Slide 31
Slide 31 text
Parametrizing fixtures and tests
let’s have multiple different “answer” fixtures:
import time, pytest
@pytest.fixture(params=[1,2,3])
def answer(request):
return request.param
the request object allows to query test invocation
information, in this case parameters.
now any tests using the answer fixture will run three
times!
Exercise: write a test function accepting an “answer”
argument and run it, also write a test that fails
() October 29, 2012 31 / 38