Repository: pypa/pip
File: tests/unit/test_collector.py (Python)

Code before:
            "git+https://example.com/repo.git@at%40%20space#egg=my-package-1.0",
        ),
        # URL with Windows drive letter, running on non-windows
        # platform. The `:` after the drive should be quoted.
        pytest.param(
            "file:///T:/path/with spaces/",
            "file:///T%3A/path/with%20spaces/",
            marks=pytest.mark.skipif("sys.platform == 'win32'"),
        ),
        # Test a VCS URL with a Windows drive letter and revision,
        # running on non-windows platform.
        pytest.param(
            "git+file:///T:/with space/repo.git@1.0#egg=my-package-1.0",
            "git+file:/T%3A/with%20space/repo.git@1.0#egg=my-package-1.0",
            marks=pytest.mark.skipif("sys.platform == 'win32'"),
        ),
    ],
)
def test_ensure_quoted_url(url: str, clean_url: str) -> None:
    assert _ensure_quoted_url(url) == clean_url


# versions containing fix/backport from https://github.com/python/cpython/pull/113563
has_new_urlun_behaviour = (
    # https://github.com/python/cpython/commit/387ff96e95b9f8a8cc7e646523ba3175b1350669
    (sys.version_info[:2] == (3, 12) and sys.version_info >= (3, 12, 4))
    or
    # https://github.com/python/cpython/commit/872000606271c52d989e53fe4cc9904343d81855
    (sys.version_info[:2] == (3, 13) and sys.version_info >= (3, 13, 0, "beta", 3))
)


@pytest.mark.skipif(
    sys.platform != "win32" or has_new_urlun_behaviour,
    reason="testing windows behaviour on older CPython",
)
@pytest.mark.parametrize(
    ("url", "clean_url"),
    (
        (
            # URL with Windows drive letter. The `:` after the drive
            # letter should not be quoted. The trailing `/` should be
            # removed.
            "file:///T:/path/with spaces/",
            "file:///T:/path/with%20spaces",
        ),
        (
            # Test a VCS URL with a Windows drive letter and revision.
            "git+file:///T:/with space/repo.git@1.0#egg=my-package-1.0",
            "git+file:///T:/with%20space/repo.git@1.0#egg=my-package-1.0",
        ),

Review comment (bug):
if we only support the latest version of Python in development we could probably drop the second check here, i.e. just check Python is `3.12` or `3.13` and inform anyone running into failures to use a newer Python. But maybe it's more convenient to just maintain the specific version for just a short time (also this is windows specific, and I imagine the number of people developing this repo on windows is very small)

Code after:
        ),
        # VCS URL with a quoted "@" in the revision string.
        (
            "git+https://example.com/repo.git@at%40 space#egg=my-package-1.0",
            "git+https://example.com/repo.git@at%40%20space#egg=my-package-1.0",
        ),
        # URL with Windows drive letter. The `:` after the drive
        # letter should not be quoted. The trailing `/` should be
        # removed.
        pytest.param(
            "file:///T:/path/with spaces/",
            "file:///T:/path/with%20spaces",
            marks=skip_needs_old_urlun_behavior_win,
        ),
        pytest.param(
            "file:///T:/path/with spaces/",
            "file://///T:/path/with%20spaces",
            marks=skip_needs_new_urlun_behavior_win,
        ),
        # URL with Windows drive letter, running on non-windows
        # platform. The `:` after the drive should be quoted.
        pytest.param(
            "file:///T:/path/with spaces/",
            "file:///T%3A/path/with%20spaces/",
            marks=pytest.mark.skipif("sys.platform == 'win32'"),
        ),
        # Test a VCS URL with a Windows drive letter and revision.
        pytest.param(
            "git+file:///T:/with space/repo.git@1.0#egg=my-package-1.0",
            "git+file:///T:/with%20space/repo.git@1.0#egg=my-package-1.0",
            marks=skip_needs_old_urlun_behavior_win,
        ),
        pytest.param(
            "git+file:///T:/with space/repo.git@1.0#egg=my-package-1.0",
            "git+file://///T:/with%20space/repo.git@1.0#egg=my-package-1.0",
            marks=skip_needs_new_urlun_behavior_win,
        ),
        # Test a VCS URL with a Windows drive letter and revision,
        # running on non-windows platform.
        pytest.param(
            "git+file:///T:/with space/repo.git@1.0#egg=my-package-1.0",
            "git+file:/T%3A/with%20space/repo.git@1.0#egg=my-package-1.0",
            marks=pytest.mark.skipif("sys.platform == 'win32'"),
        ),
    ],
)
def test_ensure_quoted_url(url: str, clean_url: str) -> None:
    assert _ensure_quoted_url(url) == clean_url


def _test_parse_links_data_attribute(