Skip to content

Commit 72b3441

Browse files
committed
Fix docs
1 parent 7b2f259 commit 72b3441

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

changelog/13228.feature.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
``pytest.HIDDEN_PARAM`` can now be used in ``id`` of ``pytest.param`` or in ``ids`` of ``parametrize``. It hides the parameter set from the test name.
1+
:ref:`pytest.HIDDEN_PARAM` can now be used in ``id`` of :func:`pytest.param` or in
2+
``ids`` of :py:func:`Metafunc.parametrize <pytest.Metafunc.parametrize>`.
3+
It hides the parameter set from the test name.

doc/en/reference/reference.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ The current pytest version, as a string::
2020
>>> pytest.__version__
2121
'7.0.0'
2222

23+
.. _`pytest.HIDDEN_PARAM ref`:
24+
25+
pytest.HIDDEN_PARAM
26+
~~~~~~~~~~~~~~~~~~~
27+
28+
.. versionadded:: 8.4
29+
30+
Can be passed to ``ids`` of :py:func:`Metafunc.parametrize <pytest.Metafunc.parametrize>`
31+
or to ``id`` of :func:`pytest.param` to hide a parameter set from the test name.
32+
Can only be used at most 1 time, as test names need to be unique.
2333

2434
.. _`version-tuple`:
2535

src/_pytest/mark/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from .expression import Expression
1414
from .expression import ParseError
15+
from .structures import _HiddenParam
1516
from .structures import EMPTY_PARAMETERSET_OPTION
1617
from .structures import get_empty_parameterset_mark
1718
from .structures import HIDDEN_PARAM
@@ -50,7 +51,7 @@
5051
def param(
5152
*values: object,
5253
marks: MarkDecorator | Collection[MarkDecorator | Mark] = (),
53-
id: str | None = None,
54+
id: str | _HiddenParam | None = None,
5455
) -> ParameterSet:
5556
"""Specify a parameter in `pytest.mark.parametrize`_ calls or
5657
:ref:`parametrized fixtures <fixture-parametrize-marks>`.
@@ -75,6 +76,12 @@ def test_eval(test_input, expected):
7576
:ref:`pytest.mark.usefixtures <pytest.mark.usefixtures ref>` cannot be added via this parameter.
7677
7778
:param id: The id to attribute to this parameter set.
79+
80+
.. versionadded: 8.4
81+
82+
:ref:`pytest.HIDDEN_PARAM` means to hide the parameter set
83+
from the test name. Can only be used at most 1 time, as
84+
test names need to be unique.
7885
"""
7986
return ParameterSet.param(*values, marks=marks, id=id)
8087

src/_pytest/python.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,8 +1209,12 @@ def parametrize(
12091209
``bool``, or ``None``.
12101210
They are mapped to the corresponding index in ``argvalues``.
12111211
``None`` means to use the auto-generated id.
1212-
``pytest.HIDDEN_PARAM`` means to hide the parameter set
1213-
from the test name.
1212+
1213+
.. versionadded: 8.4
1214+
1215+
:ref:`pytest.HIDDEN_PARAM` means to hide the parameter set
1216+
from the test name. Can only be used at most 1 time, as
1217+
test names need to be unique.
12141218
12151219
If it is a callable it will be called for each entry in
12161220
``argvalues``, and the return value is used as part of the

0 commit comments

Comments
 (0)