Skip to content

Commit a95bea7

Browse files
authored
Merge pull request #14246 from V1SHAL421/typing-allow-hidden-param-ids
Include pytest.HIDDEN_PARAM in parametrize(ids=...) type annotations
2 parents cd7592c + 560b678 commit a95bea7

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

changelog/14234.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow :ref:`pytest.HIDDEN_PARAM <hidden-param>` in :ref:`@pytest.mark.parametrize(ids=...) <pytest.mark.parametrize ref>` typing.

src/_pytest/mark/structures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ def __call__(
532532
argvalues: Collection[ParameterSet | Sequence[object] | object],
533533
*,
534534
indirect: bool | Sequence[str] = ...,
535-
ids: Iterable[None | str | float | int | bool]
535+
ids: Iterable[None | str | float | int | bool | _HiddenParam]
536536
| Callable[[Any], object | None]
537537
| None = ...,
538538
scope: ScopeName | None = ...,

testing/typing_checks.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ def check_testreport_attributes(report: TestReport) -> None:
6161
assert_type(report.location, tuple[str, int | None, str])
6262

6363

64+
# Issue #14234.
65+
@pytest.mark.parametrize("x", [1, 2], ids=[pytest.HIDDEN_PARAM, "visible"])
66+
def test_hidden_param(x: int) -> None:
67+
pass
68+
69+
6470
# Test @pytest.mark.parametrize iterator argvalues deprecation.
6571
# Will be complain about unused type ignore if doesn't work.
6672
@pytest.mark.parametrize("x", iter(range(10))) # type: ignore[deprecated]

0 commit comments

Comments
 (0)