Update tests/test_utils_hastepics.py
Run CI Tests / test (push) Successful in 1m39s

This commit is contained in:
2025-08-11 10:42:24 +02:00
parent c32f2bf152
commit d45df6441d
+14 -4
View File
@@ -3,18 +3,28 @@ import threading
import pytest
import epics
from epics.pv import PV
from epics.pv import _PVcache_
from slic.utils.hastyepics import *
def _in_pv_cache(pvname: str) -> bool:
return any(k[0] == pvname for k in _PVcache_.keys())
# ============================
# Tests
# ============================
def test_get_pv_connect_false_and_true():
pv = get_pv("TEST:SIM:VAL", connect=False)
assert isinstance(pv, PV)
assert not pv.connected
name = "TEST:SIM:VAL"
assert not _in_pv_cache(name)
pv2 = get_pv("TEST:SIM:VAL", connect=True, timeout=2.0)
pv = get_pv(name, connect=False)
assert isinstance(pv, PV)
assert _in_pv_cache(name), "PV should be in _PVcache_ after get_pv(connect=False)"
assert not pv.connected
# Now actually connect
pv2 = get_pv(name, connect=True, timeout=2.0)
assert pv2.connected