Coverage for tests/test_console_utils.py: 100%
19 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-09 04:47 +0000
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-09 04:47 +0000
1#!/usr/bin/env python3
3import logging
4import pytest
6from console_utils import bytes_to_human
7from console_utils import setup_logging
10def test_bytes_to_human() -> None:
11 """Test the bytes_to_human function with various inputs."""
12 assert bytes_to_human(0) == "0 B"
13 assert bytes_to_human(512) == "512 B"
14 assert bytes_to_human(1024) == "1.00 KB"
15 assert bytes_to_human(1536) == "1.50 KB"
16 assert bytes_to_human(1536000) == "1.46 MB"
17 assert bytes_to_human(1.5 * 1024**3) == "1.50 GB"
18 assert bytes_to_human(1.7 * 1024**4) == "1.70 TB"
19 assert bytes_to_human(1.6 * 1024**5) == "1.60 PB"
20 assert bytes_to_human(1.92 * 1024**6) == "1.92 EB"
22 with pytest.raises(ValueError):
23 bytes_to_human(-1)
26def test_setup_logging() -> None:
27 setup_logging(
28 level=logging.DEBUG,
29 path="/tmp",
30 file_name="test_debug.log")
32 setup_logging(
33 level=logging.INFO,
34 file_name="test_info.log")