This commit is contained in:
+12
-10
@@ -51,21 +51,21 @@ def strip_ansi(text):
|
||||
return ansi_escape.sub('', text)
|
||||
|
||||
# === Tests ===
|
||||
@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.GREEN),
|
||||
(-50.0, colorama.Fore.GREEN)
|
||||
@pytest.mark.parametrize("value_new, value_before, expected_color", [
|
||||
(25.0, 0.0, colorama.Fore.GREEN),
|
||||
(50.0, 25.0, colorama.Fore.GREEN),
|
||||
(75.0, 50.0, colorama.Fore.GREEN),
|
||||
(100.0, 75.0, colorama.Fore.GREEN),
|
||||
(150.0, 100.0, colorama.Fore.GREEN),
|
||||
(-50.0, 150.0, colorama.Fore.GREEN)
|
||||
])
|
||||
|
||||
def test_put_with_progress_and_repr(value, expected_color):
|
||||
def test_put_with_progress_and_repr(value_new, value_old, expected_color):
|
||||
pv = PV("TEST:VAL", connection_timeout=2.0)
|
||||
assert pv.wait_for_connection(timeout=2.0), "PV not connected"
|
||||
|
||||
pv.put(0.0, wait=True)
|
||||
assert pv.get() == pytest.approx(0.0)
|
||||
pv.put(value before, wait=True)
|
||||
assert pv.get() == value before
|
||||
|
||||
# Capture tous les prints dans une liste
|
||||
printed_lines = []
|
||||
@@ -96,6 +96,8 @@ def test_put_with_progress_and_repr(value, expected_color):
|
||||
color_matches = [line for line in printed_lines if expected_color in line]
|
||||
assert color_matches, "Expected color code not found"
|
||||
|
||||
assert value_new and value_old in printed_lines
|
||||
|
||||
# Vérifie que la valeur finale est correcte
|
||||
assert pv.get() == pytest.approx(value)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user