August 2018
Beginner
160 pages
4h 8m
English
Often, in parametrized tests, you find the need to apply one or more marks to a set of parameters as you would to a normal test function. For example, you want to apply a timeout mark to one set of parameters because it takes too long to run, or xfail a set of parameters, because it has not been implemented yet.
In those cases, use pytest.param to wrap the set of values and apply the marks you want:
@pytest.mark.parametrize( "formula, inputs, result", [ ... ("log(x) + 3", dict(x=2.71828182846), 4.0), pytest.param( "hypot(x, y)", dict(x=3, y=4), 5.0, marks=pytest.mark.xfail(reason="not implemented: #102"), ), ],)
The signature of pytest.param is this:
pytest.param(*values, **kw)
Where:
Read now
Unlock full access