Open
Description
When using pytest.param
to create parameters for a test from a function, that function will return a list of ParameterSet
but currently that is only available from _pytest.mark.structures
which is private so importing it results in a private import warning.
It would be ideal if this structure was publicly available so developers don't need to disable warnings for uses of pytest.param
when using fully hinted code.
The current situation looks like this, which requires a pyright
ignore directive to be warning free.
This is simplified example, which could be defined inline but for more complex where the test cases were built by code using a function is more necessary.
from _pytest.mark.structures import ParameterSet # pyright: ignore[reportPrivateImportUsage]
import pytest
def params() -> list[ParameterSet]:
return [
pytest.param("basic", 10, True, id="basic")
pytest.param("advanced", 5, False, id="advanced")}
]
@pytest.mark.parametrize(("val1", "val2", "expected"), params())
async def test_ratelimiter(val1: str, val2: int, expected: bool) -> None:
"""Test code goes here..."""
Ideally this would be public to avoid this, for example:
from pytest.mark.structures import ParameterSet
import pytest
def params() -> list[ParameterSet]:
return [
pytest.param("basic", 10, True, id="basic")
pytest.param("advanced", 5, False, id="advanced")}
]
@pytest.mark.parametrize(("val1", "val2", "expected"), params())
async def test_ratelimiter(val1: str, val2: int, expected: bool) -> None:
"""Test code goes here..."""