forked from pypa/pip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split up Windows tests relying on urlunparse behaviour
There was a behavioural change to `urllib.parse.urlunparse`[1] that affects some of our tests on Windows. With the understanding that the new behaviour is indeed desired, split up some tests relying on this behaviour depending on the version of Python. This currently affects only 3.12 and 3.13 but there are other backports for that change in review upstream, so we'll likely need to update this in the future. [1] python/cpython#113563
- Loading branch information
1 parent
2753c77
commit 0d33a34
Showing
1 changed file
with
61 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import logging | ||
import os | ||
import re | ||
import sys | ||
import uuid | ||
from pathlib import Path | ||
from textwrap import dedent | ||
|
@@ -377,33 +378,13 @@ def test_clean_url_path_with_local_path(path: str, expected: str) -> None: | |
"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=pytest.mark.skipif( | ||
"sys.platform != 'win32' or " | ||
"sys.version_info == (3, 13, 0, 'beta', 2)" | ||
), | ||
), | ||
# 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/[email protected]#egg=my-package-1.0", | ||
"git+file:///T:/with%20space/[email protected]#egg=my-package-1.0", | ||
marks=pytest.mark.skipif( | ||
"sys.platform != 'win32' or " | ||
"sys.version_info == (3, 13, 0, 'beta', 2)" | ||
), | ||
), | ||
# Test a VCS URL with a Windows drive letter and revision, | ||
# running on non-windows platform. | ||
pytest.param( | ||
|
@@ -417,6 +398,66 @@ 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/[email protected]#egg=my-package-1.0", | ||
"git+file:///T:/with%20space/[email protected]#egg=my-package-1.0", | ||
), | ||
), | ||
) | ||
def test_ensure_quoted_url_windows_old(url: str, clean_url: str) -> None: | ||
assert _ensure_quoted_url(url) == clean_url | ||
|
||
|
||
@pytest.mark.skipif( | ||
sys.platform != "win32" or not has_new_urlun_behaviour, | ||
reason="testing windows behaviour on newer 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/[email protected]#egg=my-package-1.0", | ||
"git+file://///T:/with%20space/[email protected]#egg=my-package-1.0", | ||
), | ||
), | ||
) | ||
def test_ensure_quoted_url_windows_new(url: str, clean_url: str) -> None: | ||
assert _ensure_quoted_url(url) == clean_url | ||
|
||
|
||
def _test_parse_links_data_attribute( | ||
anchor_html: str, attr: str, expected: Optional[str] | ||
) -> Link: | ||
|