Skip to content

Commit c108920

Browse files
committed
ruff
1 parent f725475 commit c108920

File tree

1 file changed

+67
-22
lines changed

1 file changed

+67
-22
lines changed

test_genie_python_using_simple.py

Lines changed: 67 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ def test_GIVEN_pv_reaches_correct_value_WHEN_waiting_for_pv_THEN_waitfor_returns
141141
value_to_wait_for = 2
142142

143143
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),
145146
)
146147
set_pv_thread.start()
147148
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
152153
"Waitfor should have finished because pv has changed",
153154
)
154155

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+
):
156159
pv_name = g.prefix_pv_name("SIMPLE:VALUE1:SP")
157160
g.set_pv(pv_name, 0, wait=True)
158161
value_to_wait_for = 2
@@ -184,24 +187,32 @@ def setUp(self):
184187
def tearDown(self):
185188
g.set_pv(self._pv_name + ".DISP", 0)
186189

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+
):
188193
g.set_pv(self._pv_name + ".DISP", 1)
189194
with self.assertRaises(WriteAccessException):
190195
g.set_pv(self._pv_name, "test")
191196

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+
):
193200
g.set_pv(self._pv_name + ".DISP", 0)
194201
test_value = 123
195202
time.sleep(2)
196203
g.set_pv(self._pv_name, test_value)
197204
assert g.get_pv(self._pv_name) == test_value
198205

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+
):
200209
test_value = "m"
201210
g.set_pv(self._pv_name + ".EGU", test_value)
202211
assert g.get_pv(self._pv_name + ".EGU") == test_value
203212

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+
):
205216
g.set_pv(self._pv_name + ".DISP", 1)
206217
with self.assertRaises(WriteAccessException):
207218
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
229240
args=(self.wait_before, self.wait_after, self.pv_name, value_to_wait_for),
230241
)
231242
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+
)
233246

234247
assert_that(
235248
set_pv_thread.is_alive(),
236249
is_(True),
237250
"Waitfor should have finished because block has changed to correct value",
238251
)
239252

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+
):
241256
value_to_wait_for = 2
242257
wrong_value = 3
243258

@@ -246,7 +261,9 @@ def test_GIVEN_waiting_for_exact_value_on_block_WHEN_block_wrong_value_THEN_time
246261
args=(self.wait_before, self.wait_after, self.pv_name, wrong_value),
247262
)
248263
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+
)
250267

251268
assert_that(
252269
set_pv_thread.is_alive(),
@@ -267,7 +284,10 @@ def test_GIVEN_waiting_for_value_in_limits_on_block_WHEN_block_enters_range_THEN
267284
)
268285
set_pv_thread.start()
269286
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,
271291
)
272292

273293
assert_that(
@@ -276,7 +296,9 @@ def test_GIVEN_waiting_for_value_in_limits_on_block_WHEN_block_enters_range_THEN
276296
"Waitfor should have finished because block has changed to value in range",
277297
)
278298

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+
):
280302
wrong_value = 4
281303
low_limit = 1
282304
high_limit = 3
@@ -287,7 +309,10 @@ def test_GIVEN_waiting_for_value_in_limits_on_block_WHEN_block_wrong_value_THEN_
287309
)
288310
set_pv_thread.start()
289311
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,
291316
)
292317

293318
assert_that(
@@ -307,7 +332,9 @@ def test_GIVEN_waiting_for_value_below_high_limit_on_block_WHEN_block_enters_ran
307332
args=(self.wait_before, self.wait_after, self.pv_name, value_in_range),
308333
)
309334
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+
)
311338

312339
assert_that(
313340
set_pv_thread.is_alive(),
@@ -326,7 +353,9 @@ def test_GIVEN_waiting_for_value_below_high_limit_on_block_WHEN_block_above_limi
326353
args=(self.wait_before, self.wait_after, self.pv_name, wrong_value),
327354
)
328355
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+
)
330359

331360
assert_that(
332361
set_pv_thread.is_alive(),
@@ -345,7 +374,9 @@ def test_GIVEN_waiting_for_value_above_low_limit_on_block_WHEN_block_enters_rang
345374
args=(self.wait_before, self.wait_after, self.pv_name, value_in_range),
346375
)
347376
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+
)
349380

350381
assert_that(
351382
set_pv_thread.is_alive(),
@@ -364,7 +395,9 @@ def test_GIVEN_waiting_for_value_above_low_limit_on_block_WHEN_block_below_limit
364395
args=(self.wait_before, self.wait_after, self.pv_name, wrong_value),
365396
)
366397
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+
)
368401

369402
assert_that(
370403
set_pv_thread.is_alive(),
@@ -384,7 +417,9 @@ def test_GIVEN_waiting_for_value_below_high_limit_on_block_WHEN_block_reaches_li
384417
args=(self.wait_before, self.wait_after, self.pv_name, high_limit),
385418
)
386419
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+
)
388423

389424
assert_that(
390425
set_pv_thread.is_alive(),
@@ -398,10 +433,13 @@ def test_GIVEN_waiting_for_value_above_low_limit_on_block_WHEN_block_reaches_lim
398433
low_limit = 2
399434

400435
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),
402438
)
403439
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+
)
405443

406444
assert_that(
407445
set_pv_thread.is_alive(),
@@ -543,7 +581,6 @@ def _waitfor_runstate(self, state):
543581
self.assertEqual(g.get_runstate(), state)
544582

545583

546-
547584
class SystemTestScriptChecker(unittest.TestCase):
548585
def setUp(self):
549586
g.set_instrument(None)
@@ -557,13 +594,21 @@ def test_GIVEN_invalid_inst_script_from_settings_area_WHEN_calling_script_checke
557594
self,
558595
):
559596
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",
561604
)
562605
temp_file_name = "temp_file.py"
563606

564607
script_lines_1 = "def sample_changer_scloop(a: int, b: str):\n\tpass\n"
565608

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+
]
567612

568613
with open(os.path.join(path_to_inst, temp_file_name), "w") as temp_file:
569614
temp_file.write(script_lines_1)

0 commit comments

Comments
 (0)