diff --git a/tests/test_utils_tqdm_mod.py b/tests/test_utils_tqdm_mod.py index 0a50e0110..707a64532 100644 --- a/tests/test_utils_tqdm_mod.py +++ b/tests/test_utils_tqdm_mod.py @@ -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}'" \ No newline at end of file