Skip to content

Commit

Permalink
Tweak format_size utility function to include a space (#7399)
Browse files Browse the repository at this point in the history
  • Loading branch information
xavfernandez authored Nov 25, 2019
1 parent 83a9a12 commit 9557610
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/pip/_internal/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ def ask_password(message):
def format_size(bytes):
# type: (float) -> str
if bytes > 1000 * 1000:
return '%.1fMB' % (bytes / 1000.0 / 1000)
return '%.1f MB' % (bytes / 1000.0 / 1000)
elif bytes > 10 * 1000:
return '%ikB' % (bytes / 1000)
return '%i kB' % (bytes / 1000)
elif bytes > 1000:
return '%.1fkB' % (bytes / 1000.0)
return '%.1f kB' % (bytes / 1000.0)
else:
return '%ibytes' % bytes
return '%i bytes' % bytes


def is_installable_dir(path):
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,10 +995,10 @@ def test_is_console_interactive(monkeypatch, isatty, no_stdin, expected):


@pytest.mark.parametrize('size,expected', [
(123, "123bytes"),
(1234, "1.2kB"),
(123456, "123kB"),
(1234567890, "1234.6MB"),
(123, "123 bytes"),
(1234, "1.2 kB"),
(123456, "123 kB"),
(1234567890, "1234.6 MB"),
])
def test_format_size(size, expected):
assert format_size(size) == expected

0 comments on commit 9557610

Please sign in to comment.