Update tests/test_utils_rangebar.py
Run CI Tests / test (push) Successful in 31s

This commit is contained in:
2025-07-29 21:51:20 +02:00
parent 6596b06891
commit f8e31bb5c7
+10 -10
View File
@@ -18,7 +18,7 @@ def test_full_progress_bar(capture_stdout):
bar.show(100) bar.show(100)
lines = out.getvalue().strip("\r\n").split("\r") lines = out.getvalue().strip("\r\n").split("\r")
assert lines[0].startswith("[ 0 kg |") # initial __enter__ line assert lines[0].startswith("[ 0 kg |")
expected = ( expected = (
f"[ 0 kg |{colorama.Fore.GREEN}{'' * 10}{colorama.Fore.RESET}| 100 kg ] " f"[ 0 kg |{colorama.Fore.GREEN}{'' * 10}{colorama.Fore.RESET}| 100 kg ] "
f"{colorama.Style.BRIGHT}100 kg{colorama.Style.RESET_ALL}" f"{colorama.Style.BRIGHT}100 kg{colorama.Style.RESET_ALL}"
@@ -30,7 +30,8 @@ def test_half_progress_bar(capture_stdout):
with RangeBar(0, 100, width=10, units="kg", fmt=".0f") as bar: with RangeBar(0, 100, width=10, units="kg", fmt=".0f") as bar:
bar.show(50) bar.show(50)
expected_bar = f"{'' * 5}{' ' * 4}" # à 50% pile → 5 blocs pleins, 0 partiel, 5 vides
expected_bar = f"{'' * 5}{' ' * 5}"
lines = out.getvalue().strip("\r\n").split("\r") lines = out.getvalue().strip("\r\n").split("\r")
assert lines[0].startswith("[ 0 kg |") assert lines[0].startswith("[ 0 kg |")
expected = ( expected = (
@@ -44,7 +45,7 @@ def test_zero_progress_bar(capture_stdout):
with RangeBar(0, 100, width=10, units="kg", fmt=".0f") as bar: with RangeBar(0, 100, width=10, units="kg", fmt=".0f") as bar:
bar.show(0) bar.show(0)
expected_bar = f"{''}{' ' * 9}" expected_bar = f"{' ' * 10}" # pas de bloc au tout début
lines = out.getvalue().strip("\r\n").split("\r") lines = out.getvalue().strip("\r\n").split("\r")
assert lines[0].startswith("[ 0 kg |") assert lines[0].startswith("[ 0 kg |")
expected = ( expected = (
@@ -99,15 +100,14 @@ def test_multiple_show_evolution(capture_stdout):
lines = result.strip().split("\r") lines = result.strip().split("\r")
expected_lines = [ expected_lines = [
f"[ 0 kg |{colorama.Fore.GREEN}{''}{' ' * 9}{colorama.Fore.RESET}| 100 kg ] {colorama.Style.BRIGHT}0 kg{colorama.Style.RESET_ALL}", f"[ 0 kg |{colorama.Fore.GREEN}{' ' * 10}{colorama.Fore.RESET}| 100 kg ] {colorama.Style.BRIGHT}0 kg{colorama.Style.RESET_ALL}",
f"[ 0 kg |{colorama.Fore.GREEN}{''}{' ' * 8}{colorama.Fore.RESET}| 100 kg ] {colorama.Style.BRIGHT}10 kg{colorama.Style.RESET_ALL}", f"[ 0 kg |{colorama.Fore.GREEN}{' ' * 9}{colorama.Fore.RESET}| 100 kg ] {colorama.Style.BRIGHT}10 kg{colorama.Style.RESET_ALL}",
f"[ 0 kg |{colorama.Fore.GREEN}██▌{' ' * 7}{colorama.Fore.RESET}| 100 kg ] {colorama.Style.BRIGHT}25 kg{colorama.Style.RESET_ALL}", f"[ 0 kg |{colorama.Fore.GREEN}██▌{' ' * 7}{colorama.Fore.RESET}| 100 kg ] {colorama.Style.BRIGHT}25 kg{colorama.Style.RESET_ALL}",
f"[ 0 kg |{colorama.Fore.GREEN}█████▌{' ' * 4}{colorama.Fore.RESET}| 100 kg ] {colorama.Style.BRIGHT}50 kg{colorama.Style.RESET_ALL}", f"[ 0 kg |{colorama.Fore.GREEN}{'' * 5}{' ' * 5}{colorama.Fore.RESET}| 100 kg ] {colorama.Style.BRIGHT}50 kg{colorama.Style.RESET_ALL}",
f"[ 0 kg |{colorama.Fore.GREEN}███████▌▏{' '}{colorama.Fore.RESET}| 100 kg ] {colorama.Style.BRIGHT}75 kg{colorama.Style.RESET_ALL}", f"[ 0 kg |{colorama.Fore.GREEN}{'' * 7}{' ' * 2}{colorama.Fore.RESET}| 100 kg ] {colorama.Style.BRIGHT}75 kg{colorama.Style.RESET_ALL}",
f"[ 0 kg |{colorama.Fore.GREEN}█████████{colorama.Fore.RESET}| 100 kg ] {colorama.Style.BRIGHT}90 kg{colorama.Style.RESET_ALL}", f"[ 0 kg |{colorama.Fore.GREEN}{'' * 9}{colorama.Fore.RESET}| 100 kg ] {colorama.Style.BRIGHT}90 kg{colorama.Style.RESET_ALL}",
f"[ 0 kg |{colorama.Fore.GREEN}██████████{colorama.Fore.RESET}| 100 kg ] {colorama.Style.BRIGHT}100 kg{colorama.Style.RESET_ALL}", f"[ 0 kg |{colorama.Fore.GREEN}{'' * 10}{colorama.Fore.RESET}| 100 kg ] {colorama.Style.BRIGHT}100 kg{colorama.Style.RESET_ALL}",
] ]
# Ignore the first __enter__ print
for expected in expected_lines: for expected in expected_lines:
assert expected in lines assert expected in lines