@@ -141,7 +141,8 @@ def test_GIVEN_pv_reaches_correct_value_WHEN_waiting_for_pv_THEN_waitfor_returns
141
141
value_to_wait_for = 2
142
142
143
143
set_pv_thread = threading .Thread (
144
- target = delayed_set_pv , args = (wait_before , wait_after , pv_name , value_to_wait_for )
144
+ target = delayed_set_pv ,
145
+ args = (wait_before , wait_after , pv_name , value_to_wait_for ),
145
146
)
146
147
set_pv_thread .start ()
147
148
g .adv .wait_for_pv (pv_name , value_to_wait_for , maxwait = max_wait )
@@ -152,7 +153,9 @@ def test_GIVEN_pv_reaches_correct_value_WHEN_waiting_for_pv_THEN_waitfor_returns
152
153
"Waitfor should have finished because pv has changed" ,
153
154
)
154
155
155
- def test_GIVEN_pv_change_but_not_to_correct_value_WHEN_waiting_for_pv_THEN_timeout (self ):
156
+ def test_GIVEN_pv_change_but_not_to_correct_value_WHEN_waiting_for_pv_THEN_timeout (
157
+ self ,
158
+ ):
156
159
pv_name = g .prefix_pv_name ("SIMPLE:VALUE1:SP" )
157
160
g .set_pv (pv_name , 0 , wait = True )
158
161
value_to_wait_for = 2
@@ -184,24 +187,32 @@ def setUp(self):
184
187
def tearDown (self ):
185
188
g .set_pv (self ._pv_name + ".DISP" , 0 )
186
189
187
- def test_GIVEN_disp_set_on_block_WHEN_setting_pv_value_THEN_exception_is_raised (self ):
190
+ def test_GIVEN_disp_set_on_block_WHEN_setting_pv_value_THEN_exception_is_raised (
191
+ self ,
192
+ ):
188
193
g .set_pv (self ._pv_name + ".DISP" , 1 )
189
194
with self .assertRaises (WriteAccessException ):
190
195
g .set_pv (self ._pv_name , "test" )
191
196
192
- def test_GIVEN_disp_not_set_on_block_WHEN_setting_pv_value_THEN_pv_value_is_set (self ):
197
+ def test_GIVEN_disp_not_set_on_block_WHEN_setting_pv_value_THEN_pv_value_is_set (
198
+ self ,
199
+ ):
193
200
g .set_pv (self ._pv_name + ".DISP" , 0 )
194
201
test_value = 123
195
202
time .sleep (2 )
196
203
g .set_pv (self ._pv_name , test_value )
197
204
assert g .get_pv (self ._pv_name ) == test_value
198
205
199
- def test_GIVEN_field_WHEN_setting_pv_value_THEN_field_is_set_and_disp_is_not_checked (self ):
206
+ def test_GIVEN_field_WHEN_setting_pv_value_THEN_field_is_set_and_disp_is_not_checked (
207
+ self ,
208
+ ):
200
209
test_value = "m"
201
210
g .set_pv (self ._pv_name + ".EGU" , test_value )
202
211
assert g .get_pv (self ._pv_name + ".EGU" ) == test_value
203
212
204
- def test_GIVEN_disp_is_set_on_pv_WHEN_setting_field_value_THEN_exception_is_raised (self ):
213
+ def test_GIVEN_disp_is_set_on_pv_WHEN_setting_field_value_THEN_exception_is_raised (
214
+ self ,
215
+ ):
205
216
g .set_pv (self ._pv_name + ".DISP" , 1 )
206
217
with self .assertRaises (WriteAccessException ):
207
218
g .set_pv (self ._pv_name + ".EGU" , "test" )
@@ -229,15 +240,19 @@ def test_GIVEN_waiting_for_exact_value_on_block_WHEN_block_reaches_value_THEN_wa
229
240
args = (self .wait_before , self .wait_after , self .pv_name , value_to_wait_for ),
230
241
)
231
242
set_pv_thread .start ()
232
- g .waitfor_block (block = self .block_name , value = value_to_wait_for , maxwait = self .max_wait )
243
+ g .waitfor_block (
244
+ block = self .block_name , value = value_to_wait_for , maxwait = self .max_wait
245
+ )
233
246
234
247
assert_that (
235
248
set_pv_thread .is_alive (),
236
249
is_ (True ),
237
250
"Waitfor should have finished because block has changed to correct value" ,
238
251
)
239
252
240
- def test_GIVEN_waiting_for_exact_value_on_block_WHEN_block_wrong_value_THEN_timeout (self ):
253
+ def test_GIVEN_waiting_for_exact_value_on_block_WHEN_block_wrong_value_THEN_timeout (
254
+ self ,
255
+ ):
241
256
value_to_wait_for = 2
242
257
wrong_value = 3
243
258
@@ -246,7 +261,9 @@ def test_GIVEN_waiting_for_exact_value_on_block_WHEN_block_wrong_value_THEN_time
246
261
args = (self .wait_before , self .wait_after , self .pv_name , wrong_value ),
247
262
)
248
263
set_pv_thread .start ()
249
- g .waitfor_block (block = self .block_name , value = value_to_wait_for , maxwait = self .max_wait )
264
+ g .waitfor_block (
265
+ block = self .block_name , value = value_to_wait_for , maxwait = self .max_wait
266
+ )
250
267
251
268
assert_that (
252
269
set_pv_thread .is_alive (),
@@ -267,7 +284,10 @@ def test_GIVEN_waiting_for_value_in_limits_on_block_WHEN_block_enters_range_THEN
267
284
)
268
285
set_pv_thread .start ()
269
286
g .waitfor_block (
270
- block = self .block_name , lowlimit = low_limit , highlimit = high_limit , maxwait = self .max_wait
287
+ block = self .block_name ,
288
+ lowlimit = low_limit ,
289
+ highlimit = high_limit ,
290
+ maxwait = self .max_wait ,
271
291
)
272
292
273
293
assert_that (
@@ -276,7 +296,9 @@ def test_GIVEN_waiting_for_value_in_limits_on_block_WHEN_block_enters_range_THEN
276
296
"Waitfor should have finished because block has changed to value in range" ,
277
297
)
278
298
279
- def test_GIVEN_waiting_for_value_in_limits_on_block_WHEN_block_wrong_value_THEN_timeout (self ):
299
+ def test_GIVEN_waiting_for_value_in_limits_on_block_WHEN_block_wrong_value_THEN_timeout (
300
+ self ,
301
+ ):
280
302
wrong_value = 4
281
303
low_limit = 1
282
304
high_limit = 3
@@ -287,7 +309,10 @@ def test_GIVEN_waiting_for_value_in_limits_on_block_WHEN_block_wrong_value_THEN_
287
309
)
288
310
set_pv_thread .start ()
289
311
g .waitfor_block (
290
- block = self .block_name , lowlimit = low_limit , highlimit = high_limit , maxwait = self .max_wait
312
+ block = self .block_name ,
313
+ lowlimit = low_limit ,
314
+ highlimit = high_limit ,
315
+ maxwait = self .max_wait ,
291
316
)
292
317
293
318
assert_that (
@@ -307,7 +332,9 @@ def test_GIVEN_waiting_for_value_below_high_limit_on_block_WHEN_block_enters_ran
307
332
args = (self .wait_before , self .wait_after , self .pv_name , value_in_range ),
308
333
)
309
334
set_pv_thread .start ()
310
- g .waitfor_block (block = self .block_name , highlimit = high_limit , maxwait = self .max_wait )
335
+ g .waitfor_block (
336
+ block = self .block_name , highlimit = high_limit , maxwait = self .max_wait
337
+ )
311
338
312
339
assert_that (
313
340
set_pv_thread .is_alive (),
@@ -326,7 +353,9 @@ def test_GIVEN_waiting_for_value_below_high_limit_on_block_WHEN_block_above_limi
326
353
args = (self .wait_before , self .wait_after , self .pv_name , wrong_value ),
327
354
)
328
355
set_pv_thread .start ()
329
- g .waitfor_block (block = self .block_name , highlimit = high_limit , maxwait = self .max_wait )
356
+ g .waitfor_block (
357
+ block = self .block_name , highlimit = high_limit , maxwait = self .max_wait
358
+ )
330
359
331
360
assert_that (
332
361
set_pv_thread .is_alive (),
@@ -345,7 +374,9 @@ def test_GIVEN_waiting_for_value_above_low_limit_on_block_WHEN_block_enters_rang
345
374
args = (self .wait_before , self .wait_after , self .pv_name , value_in_range ),
346
375
)
347
376
set_pv_thread .start ()
348
- g .waitfor_block (block = self .block_name , lowlimit = low_limit , maxwait = self .max_wait )
377
+ g .waitfor_block (
378
+ block = self .block_name , lowlimit = low_limit , maxwait = self .max_wait
379
+ )
349
380
350
381
assert_that (
351
382
set_pv_thread .is_alive (),
@@ -364,7 +395,9 @@ def test_GIVEN_waiting_for_value_above_low_limit_on_block_WHEN_block_below_limit
364
395
args = (self .wait_before , self .wait_after , self .pv_name , wrong_value ),
365
396
)
366
397
set_pv_thread .start ()
367
- g .waitfor_block (block = self .block_name , lowlimit = low_limit , maxwait = self .max_wait )
398
+ g .waitfor_block (
399
+ block = self .block_name , lowlimit = low_limit , maxwait = self .max_wait
400
+ )
368
401
369
402
assert_that (
370
403
set_pv_thread .is_alive (),
@@ -384,7 +417,9 @@ def test_GIVEN_waiting_for_value_below_high_limit_on_block_WHEN_block_reaches_li
384
417
args = (self .wait_before , self .wait_after , self .pv_name , high_limit ),
385
418
)
386
419
set_pv_thread .start ()
387
- g .waitfor_block (block = self .block_name , highlimit = high_limit , maxwait = self .max_wait )
420
+ g .waitfor_block (
421
+ block = self .block_name , highlimit = high_limit , maxwait = self .max_wait
422
+ )
388
423
389
424
assert_that (
390
425
set_pv_thread .is_alive (),
@@ -398,10 +433,13 @@ def test_GIVEN_waiting_for_value_above_low_limit_on_block_WHEN_block_reaches_lim
398
433
low_limit = 2
399
434
400
435
set_pv_thread = threading .Thread (
401
- target = delayed_set_pv , args = (self .wait_before , self .wait_after , self .pv_name , low_limit )
436
+ target = delayed_set_pv ,
437
+ args = (self .wait_before , self .wait_after , self .pv_name , low_limit ),
402
438
)
403
439
set_pv_thread .start ()
404
- g .waitfor_block (block = self .block_name , lowlimit = low_limit , maxwait = self .max_wait )
440
+ g .waitfor_block (
441
+ block = self .block_name , lowlimit = low_limit , maxwait = self .max_wait
442
+ )
405
443
406
444
assert_that (
407
445
set_pv_thread .is_alive (),
@@ -543,7 +581,6 @@ def _waitfor_runstate(self, state):
543
581
self .assertEqual (g .get_runstate (), state )
544
582
545
583
546
-
547
584
class SystemTestScriptChecker (unittest .TestCase ):
548
585
def setUp (self ):
549
586
g .set_instrument (None )
@@ -557,13 +594,21 @@ def test_GIVEN_invalid_inst_script_from_settings_area_WHEN_calling_script_checke
557
594
self ,
558
595
):
559
596
path_to_inst = os .path .join (
560
- "c:\\ " , "instrument" , "settings" , "config" , g .adv .get_instrument_full_name (), "Python" , "inst"
597
+ "c:\\ " ,
598
+ "instrument" ,
599
+ "settings" ,
600
+ "config" ,
601
+ g .adv .get_instrument_full_name (),
602
+ "Python" ,
603
+ "inst" ,
561
604
)
562
605
temp_file_name = "temp_file.py"
563
606
564
607
script_lines_1 = "def sample_changer_scloop(a: int, b: str):\n \t pass\n "
565
608
566
- script_lines_2 = ["from inst import temp_file\n " "temp_file.sample_changer_scloop('a',2)\n " ]
609
+ script_lines_2 = [
610
+ "from inst import temp_file\n " "temp_file.sample_changer_scloop('a',2)\n "
611
+ ]
567
612
568
613
with open (os .path .join (path_to_inst , temp_file_name ), "w" ) as temp_file :
569
614
temp_file .write (script_lines_1 )
0 commit comments