33 lines
780 B
Python
33 lines
780 B
Python
import pytest
|
|
|
|
# Paramètres simples avec id au bout
|
|
@pytest.mark.parametrize("x", [
|
|
pytest.param(1, id="one"),
|
|
pytest.param(2, id="two")
|
|
])
|
|
def test_basic_ids(x):
|
|
pass
|
|
|
|
# id au milieu avec autre kwarg (reason)
|
|
@pytest.mark.parametrize("x", [
|
|
pytest.param(10, reason="because", id="ten"),
|
|
pytest.param(20, id="twenty", marks=pytest.mark.skip(reason="nope")),
|
|
])
|
|
def test_with_reason_and_marks(x):
|
|
pass
|
|
|
|
# Plusieurs arguments positionnels
|
|
@pytest.mark.parametrize("a, b", [
|
|
pytest.param(1, 2, id="1-2"),
|
|
pytest.param(3, 4 id="3-4"),
|
|
])
|
|
def test_multiple_positional_args(a, b):
|
|
pass
|
|
|
|
# Avec un argument non-évaluable
|
|
@pytest.mark.parametrize("data", [
|
|
pytest.param(object(), id="custom-obj"),
|
|
])
|
|
def test_non_literal_with_id(data):
|
|
pass
|