MCPcopy
hub / github.com/pytest-dev/pytest / param

Function param

src/_pytest/mark/__init__.py:49–85  ·  view source on GitHub ↗

Specify a parameter in `pytest.mark.parametrize`_ calls or :ref:`parametrized fixtures <fixture-parametrize-marks>`. .. code-block:: python @pytest.mark.parametrize( "test_input,expected", [ ("3+5", 8), pytest.param("6*9", 42,

(
    *values: object,
    marks: MarkDecorator | Collection[MarkDecorator | Mark] = (),
    id: str | _HiddenParam | None = None,
)

Source from the content-addressed store, hash-verified

47
48
49def param(
50 *values: object,
51 marks: MarkDecorator | Collection[MarkDecorator | Mark] = (),
52 id: str | _HiddenParam | None = None,
53) -> ParameterSet:
54 """Specify a parameter in `pytest.mark.parametrize`_ calls or
55 :ref:`parametrized fixtures <fixture-parametrize-marks>`.
56
57 .. code-block:: python
58
59 @pytest.mark.parametrize(
60 "test_input,expected",
61 [
62 ("3+5", 8),
63 pytest.param("6*9", 42, marks=pytest.mark.xfail),
64 ],
65 )
66 def test_eval(test_input, expected):
67 assert eval(test_input) == expected
68
69 :param values: Variable args of the values of the parameter set, in order.
70
71 :param marks:
72 A single mark or a list of marks to be applied to this parameter set.
73
74 :ref:`pytest.mark.usefixtures <pytest.mark.usefixtures ref>` cannot be added via this parameter.
75
76 :type id: str | Literal[pytest.HIDDEN_PARAM] | None
77 :param id:
78 The id to attribute to this parameter set.
79
80 .. versionadded:: 8.4
81 :ref:`hidden-param` means to hide the parameter set
82 from the test name. Can only be used at most 1 time, as
83 test names need to be unique.
84 """
85 return ParameterSet.param(*values, marks=marks, id=id)
86
87
88def pytest_addoption(parser: Parser) -> None:

Callers

nothing calls this directly

Calls 1

paramMethod · 0.80

Tested by

no test coverage detected