Update tests/test_utils_tqdm_mod.py
Run CI Tests / test (push) Successful in 1m2s

This commit is contained in:
2025-07-30 15:28:19 +02:00
parent d13933c278
commit 1a014ef16d
+25 -4
View File
@@ -54,15 +54,36 @@ def test_set_progress_multiple_points():
for i, (expected_progress, expected_value) in enumerate([
("0%", "0/5"),
("20%", "1/5"),
("40%", "2/5"),
("70%", "3.5/5.0"),
("100%", "5/5"),
("20%", "1.0/5"),
("40%", "2.0/5"),
("70%", "3.5/5"),
("100%", "5.0/5"),
]):
assert re.search(r"^SetBar:\s+" + re.escape(expected_progress), lines[i])
assert expected_value in lines[i]
bar = get_bar_visual(lines[i])
# test format_sizeof rounding
def test_set_progress_decimal_precision():
f = io.StringIO()
with redirect_stdout(f):
bar = tqdm_mod(total=5, desc="FloatBar", file=f, miniters=1, mininterval=0)
bar.set(1.3333)
bar.set(3.6666)
bar.set(4.999)
bar.close()
lines = extract_lines(f.getvalue(), "FloatBar")
expected_values = [
"1.3/5",
"3.7/5",
"5.0/5",
]
for expected in expected_values:
assert any(expected in line for line in lines), f"{expected} not found in output:\n" + "\n".join(lines)
def test_custom_unit():
f = io.StringIO()
with redirect_stdout(f):