def test_collect_short_file_windows(pytester: Pytester) -> None:
    """Reproducer for #11895: short paths not collected on Windows."""
    short_path = tempfile.mkdtemp()
    if "~" not in short_path:  # pragma: no cover
        if running_on_ci():
            # On CI, we are expecting that under the current GitHub actions configuration,
            # tempfile.mkdtemp() is producing short paths, so we want to fail to prevent
            # this from silently changing without us noticing.
            pytest.fail(
                f"tempfile.mkdtemp() failed to produce a short path on CI: {short_path}"
            )
        else:
            # We want to skip failing this test locally in this situation because
            # depending on the local configuration tempfile.mkdtemp() might not produce a short path:
            # For example, user might have configured %TEMP% exactly to avoid generating short paths.
            pytest.skip(
                f"tempfile.mkdtemp() failed to produce a short path: {short_path}, skipping"
            )

    test_file = Path(short_path).joinpath("test_collect_short_file_windows.py")
    test_file.write_text("def test(): pass", encoding="UTF-8")
    result = pytester.runpytest(short_path)
    assert result.parseoutcomes() == {"passed": 1}
Reproducer for #11895: short paths not collected on Windows.
testing/test_collection.py