Skip to content

Commit 89538df

Browse files
committed
again
1 parent e263c15 commit 89538df

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/pip/_internal/models/link.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ def size(self) -> int | None:
521521
if size:
522522
return int(size)
523523
except (ValueError) as e:
524-
logger.warning(f"Could not fetch size for {self.url}: {e}")
524+
logger.warning("Could not fetch size for " + self.url + ": " + e)
525525
return None
526526

527527
@property

tests/unit/test_link.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ def test_is_vcs(self, url: str, expected: bool) -> None:
189189
link = Link(url)
190190
assert link.is_vcs is expected
191191

192+
def test_link_size(self) -> None:
193+
with patch("pip._internal.network.session.PipSession.head") as mock_head:
194+
mock_head.return_value.headers = {"Content-Length": "12345"}
195+
link = Link(url="https://example.com/package.tar.gz")
196+
assert link.size == 12345
197+
192198

193199
@pytest.mark.parametrize(
194200
"url1, url2",
@@ -242,10 +248,3 @@ def test_links_equivalent(url1: str, url2: str) -> None:
242248
def test_links_equivalent_false(url1: str, url2: str) -> None:
243249
assert not links_equivalent(Link(url1), Link(url2))
244250

245-
def test_link_size():
246-
# Mock the HTTP HEAD response
247-
with patch("pip._internal.network.session.PipSession.head") as mock_head:
248-
mock_head.return_value.headers = {"Content-Length": "12345"}
249-
250-
link = Link(url="https://example.com/package.tar.gz")
251-
assert link.size == 12345 # Verify size is correctly fetched

0 commit comments

Comments
 (0)