1
1
#!/usr/bin/env python
2
2
# -*- coding: utf-8 -*-
3
3
4
+ from builtins import str
4
5
import os
5
6
import sys
6
7
@@ -114,7 +115,7 @@ def test_format_blocks_with_empty_dict(self):
114
115
formatted_blocks = format_blocks (test_blocks )
115
116
116
117
#Assert
117
- self .assertEquals (formatted_blocks , expected_result )
118
+ self .assertEqual (formatted_blocks , expected_result )
118
119
119
120
def test_GIVEN_dict_of_ordered_blocks_WHEN_formatted_blocks_called_THEN_return_same_block_order (self ):
120
121
#Arrange
@@ -130,7 +131,7 @@ def test_GIVEN_dict_of_ordered_blocks_WHEN_formatted_blocks_called_THEN_return_s
130
131
formatted_blocks = format_blocks (test_blocks )
131
132
132
133
#Assert
133
- self .assertListEqual (expected_order_blocks .keys (), formatted_blocks .keys ())
134
+ self .assertSequenceEqual (expected_order_blocks .keys (), formatted_blocks .keys ())
134
135
135
136
136
137
def test_shorten_title_for_default_case (self ):
@@ -141,7 +142,7 @@ def test_shorten_title_for_default_case(self):
141
142
shortened_title = shorten_title (test_pv )
142
143
143
144
#Assert
144
- self .assertEquals (shortened_title , "COUNTRATE.VAL" )
145
+ self .assertEqual (shortened_title , "COUNTRATE.VAL" )
145
146
146
147
def test_shorten_title_with_rc_in_range (self ):
147
148
#Arrange
@@ -151,7 +152,7 @@ def test_shorten_title_with_rc_in_range(self):
151
152
shortened_title = shorten_title (test_pv )
152
153
153
154
#Assert
154
- self .assertEquals (shortened_title , "NEW_BLOCK:RC:INRANGE.VAL" )
155
+ self .assertEqual (shortened_title , "NEW_BLOCK:RC:INRANGE.VAL" )
155
156
156
157
def test_shorten_title_with_rc_enabled (self ):
157
158
# Arrange
@@ -161,7 +162,7 @@ def test_shorten_title_with_rc_enabled(self):
161
162
shortened_title = shorten_title (test_pv )
162
163
163
164
# Assert
164
- self .assertEquals (shortened_title , "NEW_BLOCK:RC:ENABLE.VAL" )
165
+ self .assertEqual (shortened_title , "NEW_BLOCK:RC:ENABLE.VAL" )
165
166
166
167
def test_shorten_title_with_rc_in_range (self ):
167
168
# Arrange
@@ -171,7 +172,7 @@ def test_shorten_title_with_rc_in_range(self):
171
172
shortened_title = shorten_title (test_pv )
172
173
173
174
# Assert
174
- self .assertEquals (shortened_title , "OLD_BLOCK:RC:INRANGE.VAL" )
175
+ self .assertEqual (shortened_title , "OLD_BLOCK:RC:INRANGE.VAL" )
175
176
176
177
def test_shorten_title_with_empty_string (self ):
177
178
# Arrange
@@ -181,7 +182,7 @@ def test_shorten_title_with_empty_string(self):
181
182
shortened_title = shorten_title (test_pv )
182
183
183
184
# Assert
184
- self .assertEquals (shortened_title , "" )
185
+ self .assertEqual (shortened_title , "" )
185
186
186
187
def test_shorten_title_with_bad_rc_value (self ):
187
188
# Arrange
@@ -191,7 +192,7 @@ def test_shorten_title_with_bad_rc_value(self):
191
192
shortened_title = shorten_title (test_pv )
192
193
193
194
# Assert
194
- self .assertEquals (shortened_title , "OUTRANGE.VAL" )
195
+ self .assertEqual (shortened_title , "OUTRANGE.VAL" )
195
196
196
197
def test_shorten_title_with_malformed_input_end_of_title (self ):
197
198
# Arrange
@@ -201,7 +202,7 @@ def test_shorten_title_with_malformed_input_end_of_title(self):
201
202
shortened_title = shorten_title (test_pv )
202
203
203
204
# Assert
204
- self .assertEquals (shortened_title , "INRANGE.VAL" )
205
+ self .assertEqual (shortened_title , "INRANGE.VAL" )
205
206
206
207
def test_shorten_title_with_malformed_input_rc_value (self ):
207
208
# Arrange
@@ -211,7 +212,7 @@ def test_shorten_title_with_malformed_input_rc_value(self):
211
212
shortened_title = shorten_title (test_pv )
212
213
213
214
# Assert
214
- self .assertEquals (shortened_title , "RC:INRANGE.VAL" )
215
+ self .assertEqual (shortened_title , "RC:INRANGE.VAL" )
215
216
216
217
def test_shorten_title_rc_in_pv_doesnt_count (self ):
217
218
# Arrange
@@ -221,7 +222,7 @@ def test_shorten_title_rc_in_pv_doesnt_count(self):
221
222
shortened_title = shorten_title (test_pv )
222
223
223
224
# Assert
224
- self .assertEquals (shortened_title , "RC.VAL" )
225
+ self .assertEqual (shortened_title , "RC.VAL" )
225
226
226
227
def test_shorten_title_larmor_block_high_rc (self ):
227
228
# Arrange
@@ -231,7 +232,7 @@ def test_shorten_title_larmor_block_high_rc(self):
231
232
shortened_title = shorten_title (test_pv )
232
233
233
234
# Assert
234
- self .assertEquals (shortened_title , "CJHCent:RC:HIGH.VAL" )
235
+ self .assertEqual (shortened_title , "CJHCent:RC:HIGH.VAL" )
235
236
236
237
def test_shorten_title_larmor_block_low_rc (self ):
237
238
# Arrange
@@ -241,7 +242,7 @@ def test_shorten_title_larmor_block_low_rc(self):
241
242
shortened_title = shorten_title (test_pv )
242
243
243
244
# Assert
244
- self .assertEquals (shortened_title , "Chi:RC:LOW.VAL" )
245
+ self .assertEqual (shortened_title , "Chi:RC:LOW.VAL" )
245
246
246
247
def test_when_rc_values_given_block_description_contains_rc_values (self ):
247
248
# Arrange
@@ -254,12 +255,12 @@ def test_when_rc_values_given_block_description_contains_rc_values(self):
254
255
description = test_block .get_description ()
255
256
256
257
# Assert
257
- self .assertEquals (description ["visibility" ], "OFF" )
258
- self .assertEquals (description ["status" ], "INVALID" )
259
- self .assertEquals (description ["alarm" ], "UDF_ALARM" )
260
- self .assertEquals (description ["rc_low" ], 0 )
261
- self .assertEquals (description ["rc_high" ], 100 )
262
- self .assertEquals (description ["rc_inrange" ], False )
258
+ self .assertEqual (description ["visibility" ], "OFF" )
259
+ self .assertEqual (description ["status" ], "INVALID" )
260
+ self .assertEqual (description ["alarm" ], "UDF_ALARM" )
261
+ self .assertEqual (description ["rc_low" ], 0 )
262
+ self .assertEqual (description ["rc_high" ], 100 )
263
+ self .assertEqual (description ["rc_inrange" ], False )
263
264
264
265
def test_when_rc_values_not_given_block_description_do_not_contain_rc_values (self ):
265
266
# Arrange
@@ -269,9 +270,9 @@ def test_when_rc_values_not_given_block_description_do_not_contain_rc_values(sel
269
270
description = test_block .get_description ()
270
271
271
272
# Assert
272
- self .assertEquals (description ["visibility" ], "OFF" )
273
- self .assertEquals (description ["status" ], "INVALID" )
274
- self .assertEquals (description ["alarm" ], "UDF_ALARM" )
273
+ self .assertEqual (description ["visibility" ], "OFF" )
274
+ self .assertEqual (description ["status" ], "INVALID" )
275
+ self .assertEqual (description ["alarm" ], "UDF_ALARM" )
275
276
self .assertTrue ("rc_low" not in description )
276
277
self .assertTrue ("rc_high" not in description )
277
278
self .assertTrue ("rc_inrange" not in description )
@@ -290,7 +291,7 @@ def test_set_rc_low_value_for_block_based_on_pv(self):
290
291
set_rc_values_for_blocks (blocks , runcontrol )
291
292
292
293
# Assert
293
- self .assertEquals (blocks [block_name ].get_rc_low (), expected_value )
294
+ self .assertEqual (blocks [block_name ].get_rc_low (), expected_value )
294
295
295
296
def test_set_rc_high_value_for_block_based_on_pv (self ):
296
297
# Arrange
@@ -306,8 +307,8 @@ def test_set_rc_high_value_for_block_based_on_pv(self):
306
307
set_rc_values_for_blocks (blocks , runcontrol )
307
308
308
309
# Assert
309
- self .assertEquals (blocks [block_name ].get_rc_low (), 10 )
310
- self .assertEquals (blocks [block_name ].get_rc_high (), 100 )
310
+ self .assertEqual (blocks [block_name ].get_rc_low (), 10 )
311
+ self .assertEqual (blocks [block_name ].get_rc_high (), 100 )
311
312
312
313
def test_set_rc_inrange_value_for_block_based_on_pv (self ):
313
314
# Arrange
@@ -324,9 +325,9 @@ def test_set_rc_inrange_value_for_block_based_on_pv(self):
324
325
set_rc_values_for_blocks (blocks , runcontrol )
325
326
326
327
# Assert
327
- self .assertEquals (blocks [block_name ].get_rc_low (), 10 )
328
- self .assertEquals (blocks [block_name ].get_rc_high (), 100 )
329
- self .assertEquals (blocks [block_name ].get_rc_inrange (), False )
328
+ self .assertEqual (blocks [block_name ].get_rc_low (), 10 )
329
+ self .assertEqual (blocks [block_name ].get_rc_high (), 100 )
330
+ self .assertEqual (blocks [block_name ].get_rc_inrange (), False )
330
331
331
332
def test_set_rc_not_low_value_for_block_based_on_pv (self ):
332
333
# Arrange
@@ -341,7 +342,7 @@ def test_set_rc_not_low_value_for_block_based_on_pv(self):
341
342
set_rc_values_for_blocks (blocks , runcontrol )
342
343
343
344
# Assert
344
- self .assertEquals (blocks [block_name ].get_rc_low (), None )
345
+ self .assertEqual (blocks [block_name ].get_rc_low (), None )
345
346
346
347
def test_set_rc_values_for_two_blocks_based_on_pv (self ):
347
348
# Arrange
@@ -358,8 +359,8 @@ def test_set_rc_values_for_two_blocks_based_on_pv(self):
358
359
set_rc_values_for_blocks (blocks , runcontrol )
359
360
360
361
# Assert
361
- self .assertEquals (blocks [new_block_name ].get_rc_low (), 10 )
362
- self .assertEquals (blocks [not_new_block_name ].get_rc_low (), 100 )
362
+ self .assertEqual (blocks [new_block_name ].get_rc_low (), 10 )
363
+ self .assertEqual (blocks [not_new_block_name ].get_rc_low (), 100 )
363
364
364
365
def test_set_rc_values_for_one_blocks_based_on_pv_leaves_other_unchanged (self ):
365
366
# Arrange
@@ -375,8 +376,8 @@ def test_set_rc_values_for_one_blocks_based_on_pv_leaves_other_unchanged(self):
375
376
set_rc_values_for_blocks (blocks , runcontrol )
376
377
377
378
# Assert
378
- self .assertEquals (blocks [new_block_name ].get_rc_low (), 10 )
379
- self .assertEquals (blocks [not_new_block_name ].get_rc_low (), None )
379
+ self .assertEqual (blocks [new_block_name ].get_rc_low (), 10 )
380
+ self .assertEqual (blocks [not_new_block_name ].get_rc_low (), None )
380
381
381
382
def test_set_rc_values_for_leaves_both_unchanged (self ):
382
383
# Arrange
@@ -392,14 +393,14 @@ def test_set_rc_values_for_leaves_both_unchanged(self):
392
393
set_rc_values_for_blocks (blocks , {})
393
394
394
395
# Assert
395
- self .assertEquals (blocks [block1_name ].get_rc_low (), None )
396
- self .assertEquals (blocks [block2_name ].get_rc_low (), None )
396
+ self .assertEqual (blocks [block1_name ].get_rc_low (), None )
397
+ self .assertEqual (blocks [block2_name ].get_rc_low (), None )
397
398
398
399
def test_set_rc_values_with_empty_block_list (self ):
399
400
# Act
400
401
try :
401
402
set_rc_values_for_blocks ({}, {})
402
- except Exception , e :
403
+ except Exception as e :
403
404
self .fail ("set_rc_values_for_blocks should handle empty block list" )
404
405
405
406
def _assert_blocks (self , actual_blocks , expected_blocks ):
@@ -540,6 +541,5 @@ def test_GIVEN_nonsense_precision_containing_unicode_WHEN_formatting_THEN_origin
540
541
self .assertEqual (format_block_value (value , precision ), value )
541
542
542
543
543
-
544
544
if __name__ == '__main__' :
545
545
unittest .main ()
0 commit comments