This commit is contained in:
@@ -21,10 +21,15 @@ from slic.utils.pvpreload import *
|
|||||||
# IOC simulation
|
# IOC simulation
|
||||||
@pytest.fixture(scope="module", autouse=True)
|
@pytest.fixture(scope="module", autouse=True)
|
||||||
def run_test_ioc():
|
def run_test_ioc():
|
||||||
|
stop = threading.Event()
|
||||||
|
|
||||||
def ioc():
|
def ioc():
|
||||||
with MorIOC("TEST") as mor:
|
with MorIOC("TEST") as mor:
|
||||||
|
# Declare PVs
|
||||||
mor.host(PV1=float, PV2=float, PV3=float, PV4=float, PV5=float, PV6=float)
|
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(
|
mor.serve(
|
||||||
PV1=1.0,
|
PV1=1.0,
|
||||||
PV2=2.0,
|
PV2=2.0,
|
||||||
@@ -35,9 +40,17 @@ def run_test_ioc():
|
|||||||
)
|
)
|
||||||
time.sleep(0.1)
|
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()
|
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):
|
def configure_logzero_for_pytest(caplog):
|
||||||
logger.handlers.clear()
|
logger.handlers.clear()
|
||||||
|
|||||||
Reference in New Issue
Block a user