diff --git a/tests/test_utils_pv.py b/tests/test_utils_pv.py index 55d2167f1..2233c38aa 100644 --- a/tests/test_utils_pv.py +++ b/tests/test_utils_pv.py @@ -47,17 +47,17 @@ def use_callback(pv, callback): import re def strip_ansi(text): - ansi_escape = re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]') + ansi_escape = re.compile(r'\x1b\[[0-9;]*m') return ansi_escape.sub('', text) # === Tests === -@pytest.mark.parametrize("value, expected_bar, expected_color", [ - (25.0, "██████████", colorama.Fore.GREEN), - (50.0, "██████████", colorama.Fore.GREEN), - (75.0, "██████████", colorama.Fore.GREEN), - (100.0, "██████████", colorama.Fore.GREEN), - (150.0, "██████████", colorama.Fore.RED), - (-50.0, "██████████", colorama.Fore.RED) +@pytest.mark.parametrize("value, expected_color", [ + (25.0, colorama.Fore.GREEN), + (50.0, colorama.Fore.GREEN), + (75.0, colorama.Fore.GREEN), + (100.0, colorama.Fore.GREEN), + (150.0, colorama.Fore.RED), + (-50.0, colorama.Fore.RED) ]) def test_put_with_progress_and_repr(value, expected_bar, expected_color): @@ -85,15 +85,15 @@ def test_put_with_progress_and_repr(value, expected_bar, expected_color): cleaned_lines = [strip_ansi(line) for line in printed_lines] # Initialisation bar - matches = [line for line in cleaned_lines if f"| |" in line] + matches = [line for line in cleaned_lines if f"| |" in line] assert matches, f"Expected bar '{expected_bar}' not found in:\n" + "\n".join(printed_lines) # Vérifie que la bonne barre a été affichée au moins une fois - matches = [line for line in cleaned_lines if f"|{expected_bar}|" in line] + matches = [line for line in cleaned_lines if f"|██████████████████████████████|" in line] assert matches, f"Expected bar '{expected_bar}' not found in:\n" + "\n".join(printed_lines) # Vérifie que la couleur est bien utilisée (au moins une fois dans les lignes printées) - color_matches = [line for line in cleaned_lines if expected_color in line] + color_matches = [line for line in printed_lines if expected_color in line] assert color_matches, "Expected color code not found" # Vérifie que la valeur finale est correcte