Update tests/test_utils_tqdm_mod.py
Run CI Tests / test (push) Successful in 49s

This commit is contained in:
2025-07-30 15:17:55 +02:00
parent e491d5050f
commit b71dae405d
+17 -2
View File
@@ -62,7 +62,6 @@ def test_set_progress_multiple_points():
assert re.search(r"^SetBar:\s+" + re.escape(expected_progress), lines[i])
assert expected_value in lines[i]
bar = get_bar_visual(lines[i])
assert len(bar.strip()) > 0
def test_custom_unit():
f = io.StringIO()
@@ -76,7 +75,7 @@ def test_custom_unit():
assert last.startswith("StepBar: 100%")
assert "4/4" in last
assert "step/s" in last
assert len(bar.strip()) > 0
assert len(bar.replace("", "").replace("#", "").strip()) == 0, f"Bar not full: '{bar}'"
def test_clamp_above_total():
f = io.StringIO()
@@ -95,3 +94,19 @@ def test_clamp_above_total():
# Check that the bar us full
assert len(bar.replace("", "").replace("#", "").strip()) == 0, f"Bar not full: '{bar}'"
def test_clamp_below_zero():
f = io.StringIO()
with redirect_stdout(f):
bar = tqdm_mod(total=10, desc="ClampBar", file=f)
bar.set(-1)
bar.close()
lines = extract_lines(f.getvalue(), "ClampBar")
last = lines[-1]
bar = get_bar_visual(last)
assert last.startswith("ClampBar: 0%")
assert "0/10" in last
assert "Hz" in last
# Check that the bar us full
assert len(bar.replace(" ", "").strip()) == 0, f"Bar not empty: '{bar}'"