Update tests/test_utils_pv.py
Run CI Tests / test (push) Successful in 1m15s

This commit is contained in:
2025-08-08 21:01:02 +02:00
parent f755d32000
commit ba2aea2eb8
+6 -9
View File
@@ -67,9 +67,9 @@ def strip_ansi(text):
def test_put_with_progress_and_repr(value_new, value_before, show_bar, expected_color):
pv = PV("TEST:VAL", connection_timeout=2.0)
assert pv.wait_for_connection(timeout=2.0), "PV not connected"
assert pv.wait_for_connection(), "PV not connected"
pv.put(value_before, wait=True)
pv.put(value_before)
assert pv.get() == value_before
# Capture tous les prints dans une liste
@@ -117,28 +117,25 @@ def test_use_callback_context_manager():
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)
pv.put(0.0)
seen_values = []
def callback(value=None, **kwargs):
seen_values.append(value)
with pv.use_callback(callback):
pv.put(42.0, wait=True)
time.sleep(0.2) # laisse le temps au callback de se déclencher
pv.put(42.0)
# Vérifie que le callback a bien été appelé
assert 42.0 in seen_values
with pv.use_callback(callback):
pv.put(24.0, wait=True)
time.sleep(0.2)
pv.put(24.0)
assert 24.0 in seen_values
with pv.use_callback(callback):
pv.put(75.0, wait=True)
time.sleep(0.2)
pv.put(75.0)
assert 75.0 in seen_values