Skip to content

Commit 9557610

Browse files
authored
Tweak format_size utility function to include a space (#7399)
1 parent 83a9a12 commit 9557610

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/pip/_internal/utils/misc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,13 @@ def ask_password(message):
266266
def format_size(bytes):
267267
# type: (float) -> str
268268
if bytes > 1000 * 1000:
269-
return '%.1fMB' % (bytes / 1000.0 / 1000)
269+
return '%.1f MB' % (bytes / 1000.0 / 1000)
270270
elif bytes > 10 * 1000:
271-
return '%ikB' % (bytes / 1000)
271+
return '%i kB' % (bytes / 1000)
272272
elif bytes > 1000:
273-
return '%.1fkB' % (bytes / 1000.0)
273+
return '%.1f kB' % (bytes / 1000.0)
274274
else:
275-
return '%ibytes' % bytes
275+
return '%i bytes' % bytes
276276

277277

278278
def is_installable_dir(path):

tests/unit/test_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -995,10 +995,10 @@ def test_is_console_interactive(monkeypatch, isatty, no_stdin, expected):
995995

996996

997997
@pytest.mark.parametrize('size,expected', [
998-
(123, "123bytes"),
999-
(1234, "1.2kB"),
1000-
(123456, "123kB"),
1001-
(1234567890, "1234.6MB"),
998+
(123, "123 bytes"),
999+
(1234, "1.2 kB"),
1000+
(123456, "123 kB"),
1001+
(1234567890, "1234.6 MB"),
10021002
])
10031003
def test_format_size(size, expected):
10041004
assert format_size(size) == expected

0 commit comments

Comments
 (0)