diff --git a/changelog/14234.bugfix.rst b/changelog/14234.bugfix.rst new file mode 100644 index 00000000000..5a5b8a8b3f9 --- /dev/null +++ b/changelog/14234.bugfix.rst @@ -0,0 +1 @@ +Allow :ref:`pytest.HIDDEN_PARAM ` in :ref:`@pytest.mark.parametrize(ids=...) ` typing. diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 5c9e6601e8a..21a5a34cb90 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -532,7 +532,7 @@ def __call__( argvalues: Collection[ParameterSet | Sequence[object] | object], *, indirect: bool | Sequence[str] = ..., - ids: Iterable[None | str | float | int | bool] + ids: Iterable[None | str | float | int | bool | _HiddenParam] | Callable[[Any], object | None] | None = ..., scope: ScopeName | None = ..., diff --git a/testing/typing_checks.py b/testing/typing_checks.py index 2eb8322d83a..455313d61aa 100644 --- a/testing/typing_checks.py +++ b/testing/typing_checks.py @@ -61,6 +61,12 @@ def check_testreport_attributes(report: TestReport) -> None: assert_type(report.location, tuple[str, int | None, str]) +# Issue #14234. +@pytest.mark.parametrize("x", [1, 2], ids=[pytest.HIDDEN_PARAM, "visible"]) +def test_hidden_param(x: int) -> None: + pass + + # Test @pytest.mark.parametrize iterator argvalues deprecation. # Will be complain about unused type ignore if doesn't work. @pytest.mark.parametrize("x", iter(range(10))) # type: ignore[deprecated]