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

This commit is contained in:
2025-08-09 01:39:52 +02:00
parent 740320dc95
commit 7cfe7fc64f
+16 -3
View File
@@ -21,10 +21,15 @@ from slic.utils.pvpreload import *
# IOC simulation
@pytest.fixture(scope="module", autouse=True)
def run_test_ioc():
stop = threading.Event()
def ioc():
with MorIOC("TEST") as mor:
# Declare PVs
mor.host(PV1=float, PV2=float, PV3=float, PV4=float, PV5=float, PV6=float)
while True:
# Serve loop until 'stop' is set
while not stop.is_set():
mor.serve(
PV1=1.0,
PV2=2.0,
@@ -35,9 +40,17 @@ def run_test_ioc():
)
time.sleep(0.1)
t = threading.Thread(target=ioc, daemon=True)
# Start IOC thread (not daemon so we can join it later)
t = threading.Thread(target=ioc)
t.start()
time.sleep(1)
time.sleep(1) # Give CA time to announce PVs
yield # <<< tests in this module run here >>>
# --- Teardown: stop IOC and free resources ---
stop.set()
t.join(timeout=2.0)
time.sleep(0.2)
def configure_logzero_for_pytest(caplog):
logger.handlers.clear()