Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pypa/pip
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d77af5a0fba31affbd55e9b0273b937f7c84685c
Choose a base ref
..
head repository: pypa/pip
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0beffc76b4c9c3e36aa709d24a97d68e8a796f06
Choose a head ref
Showing with 46 additions and 14 deletions.
  1. +1 −1 news/12791.bugfix.rst
  2. 0 news/5407ea34-f9bf-4f17-a201-6546bdb9d5d2.trivial.rst
  3. +17 −0 tests/lib/__init__.py
  4. +18 −9 tests/unit/test_collector.py
  5. +10 −4 tests/unit/test_urls.py
2 changes: 1 addition & 1 deletion news/12791.bugfix.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Improve performance. Fix code to display installed packages at the end of
pip install, was O(n^2) to enumerate packages due to accidental loop in loop.
pip install, was O(n^2) to enumerate packages due to accidental loop in loop.
Empty file.
17 changes: 17 additions & 0 deletions tests/lib/__init__.py
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@
Union,
cast,
)
from urllib.parse import urlparse, urlunparse
from zipfile import ZipFile

import pytest
@@ -1375,3 +1376,19 @@ def __call__(


CertFactory = Callable[[], str]

# versions containing fix/backport from https://github.com/python/cpython/pull/113563
# which changed the behavior of `urllib.parse.urlun{parse,split}`
url = "////path/to/file"
has_new_urlun_behavior = url == urlunparse(urlparse(url))

# the above change seems to only impact tests on Windows, so just add skips for that
skip_needs_new_urlun_behavior_win = pytest.mark.skipif(
sys.platform != "win32" or not has_new_urlun_behavior,
reason="testing windows behavior for newer CPython",
)

skip_needs_old_urlun_behavior_win = pytest.mark.skipif(
sys.platform != "win32" or has_new_urlun_behavior,
reason="testing windows behavior for older CPython",
)
27 changes: 18 additions & 9 deletions tests/unit/test_collector.py
Original file line number Diff line number Diff line change
@@ -35,7 +35,12 @@
_ensure_quoted_url,
)
from pip._internal.network.session import PipSession
from tests.lib import TestData, make_test_link_collector
from tests.lib import (
TestData,
make_test_link_collector,
skip_needs_new_urlun_behavior_win,
skip_needs_old_urlun_behavior_win,
)

ACCEPT = ", ".join(
[
@@ -383,10 +388,12 @@ def test_clean_url_path_with_local_path(path: str, expected: str) -> None:
pytest.param(
"file:///T:/path/with spaces/",
"file:///T:/path/with%20spaces",
marks=pytest.mark.skipif(
"sys.platform != 'win32' or "
"sys.version_info == (3, 13, 0, 'beta', 2)"
),
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.
@@ -399,10 +406,12 @@ def test_clean_url_path_with_local_path(path: str, expected: str) -> None:
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=pytest.mark.skipif(
"sys.platform != 'win32' or "
"sys.version_info == (3, 13, 0, 'beta', 2)"
),
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.
14 changes: 10 additions & 4 deletions tests/unit/test_urls.py
Original file line number Diff line number Diff line change
@@ -5,6 +5,10 @@
import pytest

from pip._internal.utils.urls import path_to_url, url_to_path
from tests.lib import (
skip_needs_new_urlun_behavior_win,
skip_needs_old_urlun_behavior_win,
)


@pytest.mark.skipif("sys.platform == 'win32'")
@@ -23,12 +27,14 @@ def test_path_to_url_unix() -> None:
pytest.param(
r"\\unc\as\path",
"file://unc/as/path",
marks=pytest.mark.skipif(
"sys.platform != 'win32' or "
"sys.version_info == (3, 13, 0, 'beta', 2)"
),
marks=skip_needs_old_urlun_behavior_win,
id="unc-path",
),
pytest.param(
r"\\unc\as\path",
"file:////unc/as/path",
marks=skip_needs_new_urlun_behavior_win,
),
],
)
def test_path_to_url_win(path: str, url: str) -> None: