This commit is contained in:
@@ -18,7 +18,7 @@ def test_full_progress_bar(capture_stdout):
|
||||
bar.show(100)
|
||||
|
||||
lines = out.getvalue().strip("\r\n").split("\r")
|
||||
assert lines[0].startswith("[ 0 kg |") # initial __enter__ line
|
||||
assert lines[0].startswith("[ 0 kg |")
|
||||
expected = (
|
||||
f"[ 0 kg |{colorama.Fore.GREEN}{'█' * 10}{colorama.Fore.RESET}| 100 kg ] "
|
||||
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:
|
||||
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")
|
||||
assert lines[0].startswith("[ 0 kg |")
|
||||
expected = (
|
||||
@@ -44,7 +45,7 @@ def test_zero_progress_bar(capture_stdout):
|
||||
with RangeBar(0, 100, width=10, units="kg", fmt=".0f") as bar:
|
||||
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")
|
||||
assert lines[0].startswith("[ 0 kg |")
|
||||
expected = (
|
||||
@@ -99,15 +100,14 @@ def test_multiple_show_evolution(capture_stdout):
|
||||
lines = result.strip().split("\r")
|
||||
|
||||
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}█{'▏'}{' ' * 8}{colorama.Fore.RESET}| 100 kg ] {colorama.Style.BRIGHT}10 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}█{' ' * 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}█████▌{' ' * 4}{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}█████████▍{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}{'█' * 5}{' ' * 5}{colorama.Fore.RESET}| 100 kg ] {colorama.Style.BRIGHT}50 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}{'█' * 9}▍{colorama.Fore.RESET}| 100 kg ] {colorama.Style.BRIGHT}90 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:
|
||||
assert expected in lines
|
||||
|
||||
Reference in New Issue
Block a user