def test_human_file_size(): items = [ # (expected, value, err) # scales ("1", 1), ("999", 999), ("1k", 1000), ("1.1M", 1.1e6), ("1.12G", 1.12e9), ("1.12T", 1.123e12), # err ("1±2", 1, 2), ("1±0.1k", 1e3, 123), ("12.3±4M", 12.34e6, 4321e3), ] for item in items: expected = item[0] got = util.human_file_size(*item[1:]) assert got == expected, item got = util.human_value(item[1], 'bytes', *item[2:]) assert got == expected, item