CS2613/labs/L14/test_humansize.py

21 lines
429 B
Python
Raw Permalink Normal View History

import pytest
from humansize import approximate_size
def test_1000():
assert approximate_size(1000000000000, False) == "1.0 TB"
def test_1024():
assert approximate_size(1000000000000) == "931.3 GiB"
def test_negative():
with pytest.raises(ValueError):
approximate_size(-1)
def test_huge_number():
with pytest.raises(ValueError):
approximate_size(1_000_000_000_000_000_000_000_000_000_000)