@@ -54,7 +54,7 @@ def assertSymbolsDefined(self, script_lines, expected_symbols):
54
54
55
55
def test_GIVEN_end_without_brackets_WHEN_check_THEN_error_message (self ):
56
56
script_lines = [
57
- "from genie_python import genie as g\n " "def test():\n " ,
57
+ "from genie_python import genie as g\n def test():\n " ,
58
58
" g.begin()\n " ,
59
59
" g.end\n " ,
60
60
]
@@ -65,14 +65,14 @@ def test_GIVEN_end_without_brackets_WHEN_check_THEN_error_message(self):
65
65
)
66
66
67
67
def test_GIVEN_end_as_start_of_another_word_WHEN_check_THEN_no_error_message (self ):
68
- script_lines = ["from genie_python import genie as g\n " "def test():\n " , " endAngle = 1" ]
68
+ script_lines = ["from genie_python import genie as g\n def test():\n " , " endAngle = 1" ]
69
69
70
70
with CreateTempScriptAndReturnErrors (self .checker , self .machine , script_lines ) as errors :
71
71
self .assertEqual (errors , [])
72
72
73
73
def test_GIVEN_end_as_end_of_another_word_WHEN_check_THEN_no_error_message (self ):
74
74
script_lines = [
75
- "from genie_python import genie as g\n " "def test():\n " ,
75
+ "from genie_python import genie as g\n def test():\n " ,
76
76
" angle_end = 1" ,
77
77
]
78
78
@@ -82,7 +82,7 @@ def test_GIVEN_end_as_end_of_another_word_WHEN_check_THEN_no_error_message(self)
82
82
self .assertEqual (errors , [])
83
83
84
84
def test_GIVEN_end_without_brackets_at_start_of_line_WHEN_check_THEN_error_message (self ):
85
- script_lines = ["from genie_python import genie as g\n " "def test():\n " " g.end" ]
85
+ script_lines = ["from genie_python import genie as g\n def test():\n g.end" ]
86
86
87
87
with CreateTempScriptAndReturnErrors (self .checker , self .machine , script_lines ) as errors :
88
88
self .assertEqual (
@@ -92,15 +92,15 @@ def test_GIVEN_end_without_brackets_at_start_of_line_WHEN_check_THEN_error_messa
92
92
def test_GIVEN_end_without_brackets_on_line_with_fn_with_brackets_WHEN_check_THEN_error_message (
93
93
self ,
94
94
):
95
- script_lines = ["from genie_python import genie as g\n " "g .begin(); g.end " ]
95
+ script_lines = ["from genie_python import genie as g\n g .begin(); g.end " ]
96
96
97
97
with CreateTempScriptAndReturnErrors (self .checker , self .machine , script_lines ) as errors :
98
98
self .assertEqual (
99
99
errors , ["W: 2: Statement seems to have no effect (pointless-statement)" ]
100
100
)
101
101
102
102
def test_GIVEN_end_in_string_without_brackets_WHEN_check_THEN_no_message (self ):
103
- script_lines = [" def test():\n " ' " a string containing end "' ]
103
+ script_lines = [' def test():\n " a string containing end "' ]
104
104
105
105
with CreateTempScriptAndReturnErrors (self .checker , self .machine , script_lines ) as errors :
106
106
self .assertEqual (errors , [])
@@ -202,9 +202,7 @@ def test_GIVEN_variable_assignment_with_g__WHEN_check_THEN_no_message(self):
202
202
self .assertEqual (errors , [])
203
203
204
204
def test_GIVEN_function_with_g_WHEN_check_THEN_warn_user (self ):
205
- script_lines = [
206
- "from genie_python import genie as g\n " "def test():\n " " g.test_function()\n "
207
- ]
205
+ script_lines = ["from genie_python import genie as g\n def test():\n g.test_function()\n " ]
208
206
209
207
with CreateTempScriptAndReturnErrors (self .checker , self .machine , script_lines ) as errors :
210
208
self .assertEqual (
@@ -214,7 +212,7 @@ def test_GIVEN_function_with_g_WHEN_check_THEN_warn_user(self):
214
212
215
213
def test_GIVEN_2_g_assignments_WHEN_check_THEN_warning_message (self ):
216
214
script_lines = [
217
- "from genie_python import genie as g\n " "def test():\n " " g=16\n " ,
215
+ "from genie_python import genie as g\n def test():\n g=16\n " ,
218
216
" g=17" ,
219
217
]
220
218
@@ -224,9 +222,7 @@ def test_GIVEN_2_g_assignments_WHEN_check_THEN_warning_message(self):
224
222
)
225
223
226
224
def test_GIVEN_g_non_existing_command_WHEN_call_THEN_error_message (self ):
227
- script_lines = [
228
- "from genie_python import genie as g\n " "def test():\n " " g.aitfor_time(10)"
229
- ]
225
+ script_lines = ["from genie_python import genie as g\n def test():\n g.aitfor_time(10)" ]
230
226
231
227
with CreateTempScriptAndReturnErrors (self .checker , self .machine , script_lines ) as errors :
232
228
self .assertEqual (
@@ -450,6 +446,20 @@ def test_GIVEN_invalid_var_type_THEN_pyright_throws_exception(self):
450
446
with CreateTempScriptAndReturnErrors (self .checker , self .machine , script_lines ) as errors :
451
447
self .assertTrue (expected in errors [0 ])
452
448
449
+ def test_GIVEN_two_get_pv_calls_with_arithmetic_operators_THEN_no_error (self ):
450
+ script_lines = [
451
+ "from genie_python import genie as g\n " ,
452
+ "a = g.get_pv('...')\n " ,
453
+ "b = g.get_pv('...')\n " ,
454
+ "added = a + b\n " ,
455
+ "subtracted = a - b\n " ,
456
+ "multiplied = a * b\n " ,
457
+ "divided = a / b\n " ,
458
+ ]
459
+
460
+ with CreateTempScriptAndReturnErrors (self .checker , self .machine , script_lines ) as errors :
461
+ self .assertListEqual (errors , [])
462
+
453
463
def test_GIVEN_new_directory_WHEN_pyright_script_checker_called_THEN_pyright_json_created_then_destroyed_after_use (
454
464
self ,
455
465
):
@@ -539,8 +549,7 @@ def test_GIVEN_trying_to_index_var_of_optional_type_WHEN_pyright_script_checker_
539
549
):
540
550
script_lines = [
541
551
"from typing import Optional, List\n " ,
542
- "def get_first_element(elements: Optional[List[int]]) -> int:\n "
543
- " return elements[0]\n " ,
552
+ "def get_first_element(elements: Optional[List[int]]) -> int:\n return elements[0]\n " ,
544
553
]
545
554
546
555
with CreateTempScriptAndReturnErrors (self .checker , self .machine , script_lines ) as errors :
@@ -563,7 +572,7 @@ def test_GIVEN_trying_to_iterate_over_var_of_optional_type_WHEN_pyright_script_c
563
572
):
564
573
script_lines = [
565
574
"from typing import Optional, List\n " ,
566
- "def iter_elements(elements: Optional[List[int]]):\n " " for element in elements:\n " ,
575
+ "def iter_elements(elements: Optional[List[int]]):\n for element in elements:\n " ,
567
576
" pass\n " ,
568
577
]
569
578
@@ -573,23 +582,23 @@ def test_GIVEN_trying_to_iterate_over_var_of_optional_type_WHEN_pyright_script_c
573
582
def test_GIVEN_trying_to_define_function_with_none_type_args_type_WHEN_pyright_script_checker_called_THEN_no_error (
574
583
self ,
575
584
):
576
- script_lines = ["def none_func(arg: int = None):\n " " print(arg)\n " ]
585
+ script_lines = ["def none_func(arg: int = None):\n print(arg)\n " ]
577
586
578
587
with CreateTempScriptAndReturnErrors (self .checker , self .machine , script_lines ) as errors :
579
588
self .assertEqual (errors , [])
580
589
581
590
def test_GIVEN_trying_to_use_optional_operand__WHEN_pyright_script_checker_called_THEN_no_error (
582
591
self ,
583
592
):
584
- script_lines = ["def none_func(arg1: int, arg2: int = None):\n " " print(arg2 + arg1)\n " ]
593
+ script_lines = ["def none_func(arg1: int, arg2: int = None):\n print(arg2 + arg1)\n " ]
585
594
586
595
with CreateTempScriptAndReturnErrors (self .checker , self .machine , script_lines ) as errors :
587
596
self .assertEqual (errors , [])
588
597
589
598
def test_GIVEN_trying_to_use_undefined_variable_WHEN_pyright_script_checker_called_THEN_no_error (
590
599
self ,
591
600
):
592
- script_lines = ["def func():\n " " print(arg)\n " ]
601
+ script_lines = ["def func():\n print(arg)\n " ]
593
602
594
603
with CreateTempScriptAndReturnErrors (
595
604
self .checker , self .machine , script_lines , no_pylint = True
0 commit comments