diff --git a/tests/test_utils_pv.py b/tests/test_utils_pv.py index 35ae7e1e4..562acd7ee 100644 --- a/tests/test_utils_pv.py +++ b/tests/test_utils_pv.py @@ -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)