August 2018
Beginner
160 pages
4h 8m
English
Consider this example:
@pytest.mark.parametrize( "formula, inputs, result", [ ("x + 3", dict(x=1.0), 4.0,), ("x - 1", dict(x=6.0), 5.0,), ],)def test_formula_simple(formula, inputs, result): ...
As we have seen, pytest automatically creates custom test IDs, based on the parameters used in a parametrized call. Running pytest -v will generate these test IDs:
======================== test session starts ========================...tests/test_formula.py::test_formula_simple[x + 3-inputs0-4.0]tests/test_formula.py::test_formula_simple[x - 1-inputs1-5.0]
If you don't like the automatically generated IDs, you can use pytest.param and the id option to customize it:
@pytest.mark.parametrize( "formula, inputs, result", [ pytest.param ...
Read now
Unlock full access