Improve rendering of size column

This commit is contained in:
Aaron Tan 2021-08-04 21:02:43 +10:00
parent 88374e958b
commit 4266c4852c
2 changed files with 2 additions and 2 deletions

View File

@ -20,7 +20,7 @@ def pretty_size(size):
if bottom[1] <= size < top[1]:
suf = bottom[0]
lim = bottom[1]
x = round(size / lim, 2)
x = round(size / lim)
if x == int(x):
x = int(x)
return str(x) + suf

View File

@ -29,7 +29,7 @@ def test_pretty_size():
assert human.pretty_size(0) == "0b"
assert human.pretty_size(100) == "100b"
assert human.pretty_size(1024) == "1k"
assert human.pretty_size(1024 + (1024 / 2.0)) == "1.5k"
assert human.pretty_size(1024 + (1024 / 2.0)) == "2k"
assert human.pretty_size(1024 * 1024) == "1m"
assert human.pretty_size(10 * 1024 * 1024) == "10m"