Skip to content

Commit 51a1b52

Browse files
committed
TST: disconnect and clear channels to avoid segfault in test cleanup
1 parent bf11aa2 commit 51a1b52

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

test/test_psp.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def test_get(pvname):
4040
pv = setup_pv(pvname)
4141
value = pv.get()
4242
assert value is not None
43+
pv.disconnect()
4344

4445

4546
@pytest.mark.timeout(10)
@@ -59,6 +60,7 @@ def test_put_get(pvname):
5960
logger.debug('caput %s %s', pvname, new_value)
6061
pv.put(new_value, timeout=1.0)
6162
assert pv.get() == new_value
63+
pv.disconnect()
6264

6365

6466
@pytest.mark.timeout(10)
@@ -83,6 +85,7 @@ def test_monitor(pvname):
8385
time.sleep(0.1)
8486
n += 1
8587
assert pv.value == new_value
88+
pv.disconnect()
8689

8790

8891
@pytest.mark.timeout(10)
@@ -95,6 +98,7 @@ def test_misc(pvname):
9598
assert isinstance(pv.count, int)
9699
assert isinstance(pv.type(), str)
97100
assert isinstance(pv.rwaccess(), int)
101+
pv.disconnect()
98102

99103

100104
@pytest.mark.timeout(10)
@@ -111,6 +115,7 @@ def test_waveform():
111115
val = pv.get()
112116
assert isinstance(val, np.ndarray)
113117
assert len(val) == pv.count
118+
pv.disconnect()
114119

115120

116121
@pytest.mark.timeout(10)
@@ -122,6 +127,7 @@ def some_thread_thing(pvname):
122127
pv = setup_pv(pvname)
123128
val = pv.get()
124129
assert isinstance(val, tuple)
130+
pv.disconnect()
125131

126132
pvname = pvbase + ":WAVE"
127133
thread = threading.Thread(target=some_thread_thing, args=(pvname,))

test/test_pyca.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def test_get_data(pvname):
124124
assert key in pv.data
125125
# check that value is not None
126126
assert pv.data['value'] is not None
127+
pv.clear_channel()
127128

128129

129130
@pytest.mark.timeout(10)
@@ -151,6 +152,7 @@ def test_put_get(pvname):
151152
assert pv.getevt_cb.wait(timeout=1)
152153
recv_value = pv.data['value']
153154
assert recv_value == new_value
155+
pv.clear_channel()
154156

155157

156158
@pytest.mark.timeout(10)
@@ -186,6 +188,7 @@ def mon_cb(exception=None):
186188
assert ev.wait(timeout=1)
187189
recv_value = pv.data['value']
188190
assert recv_value == new_value
191+
pv.clear_channel()
189192

190193

191194
@pytest.mark.timeout(10)
@@ -198,6 +201,7 @@ def test_misc(pvname):
198201
assert isinstance(pv.count(), int)
199202
assert isinstance(pv.type(), str)
200203
assert isinstance(pv.rwaccess(), int)
204+
pv.clear_channel()
201205

202206

203207
@pytest.mark.timeout(10)
@@ -221,6 +225,7 @@ def test_waveform():
221225
val = pv.data['value']
222226
assert isinstance(val, np.ndarray)
223227
assert len(val) == pv.count()
228+
pv.clear_channel()
224229

225230

226231
@pytest.mark.timeout(10)
@@ -234,6 +239,7 @@ def some_thread_thing(pvname):
234239
pyca.flush_io()
235240
assert pv.getevt_cb.wait(timeout=1)
236241
assert isinstance(pv.data['value'], tuple)
242+
pv.clear_channel()
237243

238244
pvname = pvbase + ":WAVE"
239245
thread = threading.Thread(target=some_thread_thing, args=(pvname,))

0 commit comments

Comments
 (0)