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

This commit is contained in:
2025-08-07 15:42:18 +02:00
parent 5aa52e1552
commit 6f22f0a648
+18 -8
View File
@@ -114,22 +114,32 @@ def test_put_with_progress_and_repr(value_new, value_before, expected_color):
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, wait=True)
seen_values = []
def callback(value=None, **kwargs):
seen_values.append(value)
initial_count = len(pv._callbacks)
with use_callback(pv, callback):
assert len(pv._callbacks) == initial_count + 1
with pv.use_callback(callback):
pv.put(42.0, wait=True)
time.sleep(0.2)
assert 42.0 in seen_values
time.sleep(0.2) # laisse le temps au callback de se déclencher
# 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)
assert 24.0 in seen_values
with pv.use_callback(callback):
pv.put(75.0, wait=True)
time.sleep(0.2)
assert 75.0 in seen_values
assert len(pv._callbacks) == initial_count
def test_orig_repr_is_not_custom_repr():
pv = PV("TEST:VAL", connection_timeout=2.0)