Skip to content

Commit 19cdc19

Browse files
committed
Improve path_to_url() tests
Use `urllib.parse.quote()` rather than `urllib.request.pathname2url()` to generate expected URLs in tests for `path_to_url()`. This makes expectations a little more explicit. (The implementation of `path_to_url()` itself calls `pathname2url()`, and so we were marking our own homework!)
1 parent a4b40f6 commit 19cdc19

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

news/7dab557a-8fb5-41c5-afae-a92c8ab02aba.trivial.rst

Whitespace-only changes.

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def should_update_common_wheels() -> bool:
6767
# -----------------------------------------------------------------------------
6868
# Development Commands
6969
# -----------------------------------------------------------------------------
70-
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13", "pypy3"])
70+
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "pypy3"])
7171
def test(session: nox.Session) -> None:
7272
# Get the common wheels.
7373
if should_update_common_wheels():

tests/unit/test_urls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import sys
3-
import urllib.request
3+
import urllib.parse
44

55
import pytest
66

@@ -11,7 +11,7 @@
1111
def test_path_to_url_unix() -> None:
1212
assert path_to_url("/tmp/file") == "file:///tmp/file"
1313
path = os.path.join(os.getcwd(), "file")
14-
assert path_to_url("file") == "file://" + urllib.request.pathname2url(path)
14+
assert path_to_url("file") == "file://" + urllib.parse.quote(path)
1515

1616

1717
@pytest.mark.skipif("sys.platform != 'win32'")
@@ -39,7 +39,7 @@ def test_unc_path_to_url_win() -> None:
3939
@pytest.mark.skipif("sys.platform != 'win32'")
4040
def test_relative_path_to_url_win() -> None:
4141
resolved_path = os.path.join(os.getcwd(), "file")
42-
assert path_to_url("file") == "file:" + urllib.request.pathname2url(resolved_path)
42+
assert path_to_url("file") == "file:///" + urllib.parse.quote(resolved_path, safe="/:")
4343

4444

4545
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)