def test_hide_pytest_internal_warnings(
    pytester: Pytester, ignore_pytest_warnings
) -> None:
    """Make sure we can ignore internal pytest warnings using a warnings filter."""
    pytester.makepyfile(
        """
        import pytest
        import warnings

        warnings.warn(pytest.PytestWarning("some internal warning"))

        def test_bar():
            pass
    """
    )
    if ignore_pytest_warnings == "ini":
        pytester.makeini(
            """
            [pytest]
            filterwarnings = ignore::pytest.PytestWarning
        """
        )
    args = (
        ["-W", "ignore::pytest.PytestWarning"]
        if ignore_pytest_warnings == "cmdline"
        else []
    )
    result = pytester.runpytest(*args)
    if ignore_pytest_warnings != "no":
        assert WARNINGS_SUMMARY_HEADER not in result.stdout.str()
    else:
        result.stdout.fnmatch_lines(
            [
                f"*== {WARNINGS_SUMMARY_HEADER} ==*",
                "*test_hide_pytest_internal_warnings.py:4: PytestWarning: some internal warning",
                "* 1 passed, 1 warning *",
            ]
        )
Make sure we can ignore internal pytest warnings using a warnings filter.
testing/test_warnings.py