Skip to content

Commit e4bb0e9

Browse files
committed
Update test cases for case:
self.assertTrue(output == expected) to self.assertEquals(expected, output )
1 parent 69f77c6 commit e4bb0e9

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

about_code_tool/tests/test_genabout.py

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ def test_get_input_list(self):
3737
expected_list = [{'about_file': 'about.ABOUT', 'about_resource': '.',
3838
'name': 'ABOUT tool', 'version': '0.8.1'}]
3939
list = gen.get_input_list(test_input)
40-
self.assertTrue(list == expected_list)
40+
self.assertEquals(list, expected_list)
4141

4242
def test_get_input_list_covert_all_keys_to_lower(self):
4343
gen = genabout.GenAbout()
4444
test_input = join(TESTDATA_PATH, "test_files_for_genabout/about_key_with_upper_case.csv")
4545
expected_list = [{'about_file': 'about.ABOUT', 'about_resource': '.',
4646
'name': 'ABOUT tool', 'version': '0.8.1'}]
4747
list = gen.get_input_list(test_input)
48-
self.assertTrue(list == expected_list)
48+
self.assertEquals(list, expected_list)
4949

5050
def test_get_non_empty_rows_list(self):
5151
gen = genabout.GenAbout()
@@ -56,7 +56,7 @@ def test_get_non_empty_rows_list(self):
5656
expected_list = [{'about_file': '/about.ABOUT', 'about_resource': '.',
5757
'name': 'ABOUT tool', 'version': '0.8.1'}]
5858
output = gen.get_non_empty_rows_list(input_list)
59-
self.assertTrue(output == expected_list)
59+
self.assertEquals(output, expected_list)
6060

6161

6262
def test_get_mapping_list(self):
@@ -66,7 +66,7 @@ def test_get_mapping_list(self):
6666
'name': 'component',
6767
'copyright': 'confirmed copyright'}
6868
output = gen.get_mapping_list()
69-
self.assertTrue(output == expected_list)
69+
self.assertEquals(output, expected_list)
7070

7171
def test_convert_input_list(self):
7272
gen = genabout.GenAbout()
@@ -80,7 +80,7 @@ def test_convert_input_list(self):
8080
'name': 'OpenSans Fonts', 'ignore field': 'i',
8181
'version': '1', 'about_resource': 'opensans'}]
8282
output = gen.convert_input_list(input_list, mapping_list)
83-
self.assertTrue(output == expected_list)
83+
self.assertEquals(output, expected_list)
8484

8585
def test_validate_value_in_essential_missing_about_file(self):
8686
gen = genabout.GenAbout()
@@ -128,13 +128,13 @@ def test_get_duplicated_keys_have_dup(self):
128128
gen = genabout.GenAbout()
129129
test_input = join(TESTDATA_PATH, "test_files_for_genabout/dup_keys.csv")
130130
expected_list = ['copyright', 'copyright']
131-
self.assertTrue(gen.get_duplicated_keys(test_input) == expected_list)
131+
self.assertEquals(gen.get_duplicated_keys(test_input), expected_list)
132132

133133
def test_get_duplicated_keys_have_dup_diff_case(self):
134134
gen = genabout.GenAbout()
135135
test_input = join(TESTDATA_PATH, "test_files_for_genabout/dup_keys_with_diff_case.csv")
136136
expected_list = ['copyright', 'Copyright']
137-
self.assertTrue(gen.get_duplicated_keys(test_input) == expected_list)
137+
self.assertEquals(gen.get_duplicated_keys(test_input), expected_list)
138138

139139
def test_validate_mandatory_fields_no_missing(self):
140140
gen = genabout.GenAbout()
@@ -163,7 +163,7 @@ def test_get_non_supported_fields(self):
163163
'about_resource': 'opensans'}]
164164
non_supported_list = gen.get_non_supported_fields(input)
165165
expected_list = ['non_supported field']
166-
self.assertTrue(non_supported_list == expected_list)
166+
self.assertEquals(non_supported_list, expected_list)
167167

168168
def test_get_only_supported_fields(self):
169169
gen = genabout.GenAbout()
@@ -173,7 +173,7 @@ def test_get_only_supported_fields(self):
173173
expected_list = [{'about_file': '/about.ABOUT', 'about_resource': '.',
174174
'name': 'ABOUT tool', 'version': '0.8.1'}]
175175
ignore_key_list = ['non_supported']
176-
self.assertTrue(expected_list == gen.get_only_supported_fields(input_list, ignore_key_list))
176+
self.assertEquals(expected_list, gen.get_only_supported_fields(input_list, ignore_key_list))
177177

178178
def test_get_dje_license_list_no_gen_license_with_no_license_text_file_key(self):
179179
gen = genabout.GenAbout()
@@ -184,7 +184,7 @@ def test_get_dje_license_list_no_gen_license_with_no_license_text_file_key(self)
184184
gen_license = False
185185
dje_license_dict = {}
186186
lic_output_list = gen.get_dje_license_list(gen_location, input_list, gen_license, dje_license_dict)
187-
self.assertTrue(expected_output_list == lic_output_list)
187+
self.assertEquals(expected_output_list, lic_output_list)
188188
self.assertFalse(gen.warnings, "No warnings should be returned.")
189189
self.assertFalse(gen.errors, "No errors should be returned.")
190190

@@ -198,7 +198,7 @@ def test_get_dje_license_list_no_gen_license_with_license_text_file_key_not_exis
198198
gen_license = False
199199
dje_license_dict = {}
200200
lic_output_list = gen.get_dje_license_list(gen_location, input_list, gen_license, dje_license_dict)
201-
self.assertTrue(expected_output_list == lic_output_list)
201+
self.assertEquals(expected_output_list, lic_output_list)
202202
self.assertFalse(gen.warnings, "No warnings should be returned.")
203203
self.assertTrue(len(gen.errors) == 1, "Should return 1 error.")
204204

@@ -212,7 +212,7 @@ def test_get_dje_license_list_file_no_gen_license_with_license_text_file_key_exi
212212
gen_license = False
213213
dje_license_dict = {}
214214
lic_output_list = gen.get_dje_license_list(gen_location, input_list, gen_license, dje_license_dict)
215-
self.assertTrue(expected_output_list == lic_output_list)
215+
self.assertEquals(expected_output_list, lic_output_list)
216216
self.assertFalse(gen.warnings, "No warnings should be returned.")
217217
self.assertFalse(gen.errors, "No errors should be returned.")
218218

@@ -226,7 +226,7 @@ def test_get_dje_license_list_dir_no_gen_license_with_license_text_file_key_exis
226226
gen_license = False
227227
dje_license_dict = {}
228228
lic_output_list = gen.get_dje_license_list(gen_location, input_list, gen_license, dje_license_dict)
229-
self.assertTrue(expected_output_list == lic_output_list)
229+
self.assertEquals(expected_output_list, lic_output_list)
230230
self.assertFalse(gen.warnings, "No warnings should be returned.")
231231
self.assertFalse(gen.errors, "No errors should be returned.")
232232

@@ -241,7 +241,7 @@ def test_get_dje_license_list_file_gen_license_with_license_text_file_key_exist(
241241
gen_license = True
242242
dje_license_dict = {'Apache License 2.0': [u'apache-2.0', 'test context']}
243243
lic_output_list = gen.get_dje_license_list(gen_location, input_list, gen_license, dje_license_dict)
244-
self.assertTrue(expected_output_list == lic_output_list)
244+
self.assertEquals(expected_output_list, lic_output_list)
245245
self.assertFalse(gen.warnings, "No warnings should be returned.")
246246
self.assertFalse(gen.errors, "No errors should be returned.")
247247

@@ -258,8 +258,8 @@ def test_get_dje_license_list_gen_license_with_dje_license_key_empty_license_tex
258258
dje_license_dict = {'Apache License 2.0': [u'apache-2.0', 'test context']}
259259
lic_output_list = gen.get_dje_license_list(gen_location, input_list, gen_license, dje_license_dict)
260260
for line in input_list:
261-
self.assertTrue(line['license_text_file'] == 'apache-2.0.LICENSE')
262-
self.assertTrue(expected_output_list == lic_output_list)
261+
self.assertEquals(line['license_text_file'], 'apache-2.0.LICENSE')
262+
self.assertEquals(expected_output_list, lic_output_list)
263263
self.assertFalse(gen.warnings, "No warnings should be returned.")
264264
self.assertFalse(gen.errors, "No errors should be returned.")
265265

@@ -273,7 +273,7 @@ def test_get_dje_license_list_gen_license_with_empty_dje_license_key_empty_licen
273273
gen_license = True
274274
dje_license_dict = {'Apache License 2.0': [u'apache-2.0', 'test context']}
275275
lic_output_list = gen.get_dje_license_list(gen_location, input_list, gen_license, dje_license_dict)
276-
self.assertTrue(expected_output_list == lic_output_list)
276+
self.assertEquals(expected_output_list, lic_output_list)
277277
self.assertTrue(len(gen.warnings) == 1, "Should return 1 warning.")
278278
self.assertFalse(gen.errors, "No errors should be returned.")
279279

@@ -289,8 +289,8 @@ def test_get_dje_license_list_gen_license_with_dje_license_key_no_license_text_f
289289
dje_license_dict = {'Apache License 2.0': [u'apache-2.0', 'test context']}
290290
lic_output_list = gen.get_dje_license_list(gen_location, input_list, gen_license, dje_license_dict)
291291
for line in input_list:
292-
self.assertTrue(line['license_text_file'] == 'apache-2.0.LICENSE')
293-
self.assertTrue(expected_output_list == lic_output_list)
292+
self.assertEquals(line['license_text_file'], 'apache-2.0.LICENSE')
293+
self.assertEquals(expected_output_list, lic_output_list)
294294
self.assertFalse(gen.warnings, "No warnings should be returned.")
295295
self.assertFalse(gen.errors, "No errors should be returned.")
296296

@@ -305,7 +305,7 @@ def test_pre_generation_about_is_dir_exists_action_0(self):
305305
'about_resource_path' : '/TESTCASE/',
306306
'about_resource': '.', 'name': 'ABOUT tool'}]]
307307
output_list = gen.pre_generation(gen_location, input_list, action_num, False)
308-
self.assertTrue(expected_output_list == output_list)
308+
self.assertEquals(expected_output_list, output_list)
309309
self.assertFalse(gen.warnings, "No warnings should be returned.")
310310
self.assertFalse(gen.errors, "No errors should be returned.")
311311

@@ -317,7 +317,7 @@ def test_pre_generation_about_exists_action_0(self):
317317
'about_resource': '.', 'name': 'ABOUT tool'}]
318318
expected_output_list = []
319319
output_list = gen.pre_generation(gen_location, input_list, action_num, False)
320-
self.assertTrue(expected_output_list == output_list, "This output_list should be empty.")
320+
self.assertEquals(expected_output_list, output_list)
321321
self.assertTrue(len(gen.warnings) == 1, "Should return 1 warnings.")
322322
self.assertFalse(gen.errors, "No errors should be returned.")
323323

@@ -330,7 +330,7 @@ def test_pre_generation_about_exists_action_1(self):
330330
{'about_file': '/about.py.ABOUT', 'version': '0.8.2',
331331
'about_resource': '.', 'name': 'ABOUT tool'}]]
332332
output_list = gen.pre_generation(GEN_LOCATION, input_list, action_num, False)
333-
self.assertTrue(expected_output_list == expected_output_list)
333+
self.assertEquals(expected_output_list, expected_output_list)
334334
self.assertFalse(gen.warnings, "No warnings should be returned.")
335335
self.assertFalse(gen.errors, "No errors should be returned.")
336336

@@ -344,7 +344,7 @@ def test_pre_generation_about_exists_action_2(self):
344344
'about_resource_path': '/about.py.ABOUT',
345345
'version': '0.8.1', 'test': 'test sample', 'about_resource': '.'}]]
346346
output_list = gen.pre_generation(GEN_LOCATION, input_list, action_num, False)
347-
self.assertTrue(expected_output_list == output_list)
347+
self.assertEquals(expected_output_list, output_list)
348348
self.assertFalse(gen.warnings, "No warnings should be returned.")
349349
self.assertFalse(gen.errors, "No errors should be returned.")
350350

@@ -358,7 +358,7 @@ def test_pre_generation_about_exists_action_3(self):
358358
'about_resource_path': '/about.py.ABOUT',
359359
'about_resource': '.', 'name': '', 'test': 'test sample'}]]
360360
output_list = gen.pre_generation(GEN_LOCATION, input_list, action_num, False)
361-
self.assertTrue(expected_output_list == output_list)
361+
self.assertEquals(expected_output_list, output_list)
362362
self.assertFalse(gen.warnings, "No warnings should be returned.")
363363
self.assertFalse(gen.errors, "No errors should be returned.")
364364

@@ -373,7 +373,7 @@ def test_pre_generation_all_in_one(self):
373373
output_list = gen.pre_generation(GEN_LOCATION, input_list, action_num, True)
374374
self.assertFalse(os.path.exists('testdata/test_files_for_genabout/test_generation'),
375375
"This directory shouldn't be generaetd as the all_in_one is set to True.")
376-
self.assertTrue(expected_output_list == output_list, "This output_list should be empty.")
376+
self.assertEquals(expected_output_list, output_list)
377377
self.assertTrue(len(gen.warnings) == 1, "Should return 1 warning.")
378378
self.assertFalse(gen.errors, "No errors should be returned.")
379379

@@ -438,7 +438,7 @@ def test_verify_files_existance_not_exist(self):
438438
path = '.'
439439
expected_list = []
440440
output = gen.verify_files_existance(input_list, path, False)
441-
self.assertTrue(expected_list == output)
441+
self.assertEquals(expected_list, output)
442442
self.assertTrue(len(gen.warnings) == 1, "Should return 1 warning.")
443443
self.assertFalse(gen.errors, "No errors should be returned.")
444444

@@ -450,7 +450,7 @@ def test_verify_files_existance_not_exist_license_in_project(self):
450450
path = '.'
451451
expected_list = []
452452
output = gen.verify_files_existance(input_list, path, False)
453-
self.assertTrue(expected_list == output)
453+
self.assertEquals(expected_list, output)
454454
self.assertTrue(len(gen.warnings) == 1, "Should return 1 warning.")
455455
self.assertFalse(gen.errors, "No errors should be returned.")
456456

@@ -469,7 +469,7 @@ def test_gen_license_list_license_text_file_no_value(self):
469469
'license_text_file': '', 'about_resource': 'opensans'}
470470
expected_list = ('/tmp/3pp/opensans', 'Apache License 2.0')
471471
output = gen.gen_license_list(input_list)
472-
self.assertTrue(expected_list == output)
472+
self.assertEquals(expected_list, output)
473473

474474
def test_gen_license_list_no_license_text_file_key(self):
475475
gen = genabout.GenAbout()
@@ -479,7 +479,7 @@ def test_gen_license_list_no_license_text_file_key(self):
479479
'about_resource': 'opensans'}
480480
expected_list = ('/tmp/3pp/opensans', 'Apache License 2.0')
481481
output = gen.gen_license_list(input_list)
482-
self.assertTrue(expected_list == output)
482+
self.assertEquals(expected_list, output)
483483

484484
def test_copy_files_test_path_not_endswith_slash(self):
485485
gen = genabout.GenAbout()
@@ -488,7 +488,7 @@ def test_copy_files_test_path_not_endswith_slash(self):
488488
project_path = os.path.abspath('.')
489489
tmp_path = tempfile.mkdtemp()
490490
gen.copy_files(tmp_path, input_list)
491-
self.assertTrue(expected_list == os.listdir(tmp_path))
491+
self.assertEquals(expected_list, os.listdir(tmp_path))
492492
# According to the doc, the user of mkdtemp() is responsible for
493493
# deleting the temporary directory and its contents when done with it.
494494
shutil.rmtree(tmp_path)
@@ -500,7 +500,7 @@ def test_copy_files_test_path_endswith_slash(self):
500500
project_path = os.path.abspath('.')
501501
tmp_path = tempfile.mkdtemp() + '/'
502502
gen.copy_files(tmp_path, input_list)
503-
self.assertTrue(expected_list == os.listdir(tmp_path))
503+
self.assertEquals(expected_list, os.listdir(tmp_path))
504504
# According to the doc, the user of mkdtemp() is responsible for
505505
# deleting the temporary directory and its contents when done with it.
506506
shutil.rmtree(tmp_path)
@@ -516,7 +516,7 @@ def test_write_licenses(self):
516516
context = ''
517517
for line in file_in.readlines():
518518
context = line
519-
self.assertTrue(context == tmp_license_context)
519+
self.assertEquals(context, tmp_license_context)
520520
os.close(fh)
521521
os.remove(tmp_license_name)
522522

@@ -527,7 +527,7 @@ def test_process_dje_licenses(self):
527527
test_path = '/test'
528528
expected_output = [[join(u'/test', 'test_key.LICENSE'), 'This is a test license.']]
529529
output = gen.process_dje_licenses(test_license_list, test_license_dict, test_path)
530-
self.assertTrue(output == expected_output)
530+
self.assertEquals(output, expected_output)
531531

532532
def test_update_about_resource_about_file_and_field_exist(self):
533533
gen = genabout.GenAbout()
@@ -542,15 +542,15 @@ def test_update_about_resource_about_file_and_field_not_exist_isFile(self):
542542
expected_output = {'about_file': '/tmp/test.c', 'about_resource': 'test.c'}
543543
about_file_exist = True
544544
gen.update_about_resource(input_dict, about_file_exist)
545-
self.assertTrue(input_dict == expected_output)
545+
self.assertEquals(input_dict, expected_output)
546546

547547
def test_update_about_resource_about_file_and_field_not_exist_isdir(self):
548548
gen = genabout.GenAbout()
549549
input_dict = {'about_file': '/tmp/test/'}
550550
expected_output = {'about_file': '/tmp/test/', 'about_resource': '.'}
551551
about_file_exist = True
552552
gen.update_about_resource(input_dict, about_file_exist)
553-
self.assertTrue(input_dict == expected_output)
553+
self.assertEquals(input_dict, expected_output)
554554

555555
def test_update_about_resource_no_about_file_field_exist(self):
556556
gen = genabout.GenAbout()
@@ -565,15 +565,15 @@ def test_update_about_resource_no_about_file_no_field_isFile(self):
565565
expected_output = {'about_file': '/tmp/test.c', 'about_resource': 'test.c'}
566566
about_file_exist = False
567567
gen.update_about_resource(input_dict, about_file_exist)
568-
self.assertTrue(input_dict == expected_output)
568+
self.assertEquals(input_dict, expected_output)
569569

570570
def test_update_about_resource_no_about_file_no_field_isdir(self):
571571
gen = genabout.GenAbout()
572572
input_dict = {'about_file': '/tmp/test/'}
573573
expected_output = {'about_file': '/tmp/test/', 'about_resource': '.'}
574574
about_file_exist = False
575575
gen.update_about_resource(input_dict, about_file_exist)
576-
self.assertTrue(input_dict == expected_output)
576+
self.assertEquals(input_dict, expected_output)
577577

578578
def test_update_about_resource_path_about_file_field_exist(self):
579579
gen = genabout.GenAbout()
@@ -588,15 +588,15 @@ def test_update_about_resource_path_about_file_field_not_exist_isFile(self):
588588
expected_output = {'about_file': '/tmp/test.c', 'about_resource_path': '/tmp/test.c'}
589589
about_file_exist = True
590590
gen.update_about_resource_path(input_dict, about_file_exist)
591-
self.assertTrue(input_dict == expected_output)
591+
self.assertEquals(input_dict, expected_output)
592592

593593
def test_update_about_resource_path_about_file_field_not_exist_isDir(self):
594594
gen = genabout.GenAbout()
595595
input_dict = {'about_file': '/tmp/test/'}
596596
expected_output = {'about_file': '/tmp/test/', 'about_resource_path': '/tmp/test/'}
597597
about_file_exist = True
598598
gen.update_about_resource_path(input_dict, about_file_exist)
599-
self.assertTrue(input_dict == expected_output)
599+
self.assertEquals(input_dict, expected_output)
600600

601601
def test_update_about_resource_path_no_about_file_field_exist(self):
602602
gen = genabout.GenAbout()
@@ -611,14 +611,14 @@ def test_update_about_resource_path_no_about_file_field_not_exist_isFile(self):
611611
expected_output = {'about_file': '/tmp/test.c', 'about_resource_path': '/tmp/test.c'}
612612
about_file_exist = False
613613
gen.update_about_resource_path(input_dict, about_file_exist)
614-
self.assertTrue(input_dict == expected_output)
614+
self.assertEquals(input_dict, expected_output)
615615

616616
def test_update_about_resource_path_no_about_file_field_not_exist_isDir(self):
617617
gen = genabout.GenAbout()
618618
input_dict = {'about_file': '/tmp/test/'}
619619
expected_output = {'about_file': '/tmp/test/', 'about_resource_path': '/tmp/test/'}
620620
about_file_exist = False
621621
gen.update_about_resource_path(input_dict, about_file_exist)
622-
self.assertTrue(input_dict == expected_output)
622+
self.assertEquals(input_dict, expected_output)
623623

624624

0 commit comments

Comments
 (0)