def test_importorskip_module_level(pytester: Pytester) -> None:
    """`importorskip` must be able to skip entire modules when used at module level."""
    pytester.makepyfile(
        """
        import pytest
        foobarbaz = pytest.importorskip("foobarbaz")

        def test_foo():
            pass
    """
    )
    result = pytester.runpytest()
    result.stdout.fnmatch_lines(["*collected 0 items / 1 skipped*"])
`importorskip` must be able to skip entire modules when used at module level.
testing/test_runner.py