Skip to content

Commit 2f8e68a

Browse files
committed
add test code and update wording format.
1 parent 9208bce commit 2f8e68a

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

about_code_tool/genattrib.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ def convert_dict_key_to_lower_case(input_list):
9191
def check_about_file_existance_and_format(input_list):
9292
try:
9393
for row in input_list:
94-
# Force the path to start with the '/' to do the mapping
95-
# with the project structure
94+
# Force the path to start with the '/' to map with the project structure
9695
if not row['about_file'].startswith('/'):
9796
row['about_file'] = '/' + row['about_file']
9897
return input_list
@@ -208,12 +207,15 @@ def main(parser, options, args):
208207
# Clear the log file
209208
with open(join(dirname(output_path), LOG_FILENAME), 'w'):
210209
pass
211-
210+
212211
file_handler = logging.FileHandler(join(dirname(output_path), LOG_FILENAME))
213212
file_logger.addHandler(file_handler)
214213
for error_msg in errors:
215-
logger.error(error_msg)
216-
file_logger.error(error_msg)
214+
logger.error(error_msg)
215+
file_logger.error(error_msg)
216+
if errors:
217+
print("%d errors detected." % len(errors))
218+
217219
else:
218220
# we should never reach this
219221
assert False, "Unsupported option(s)."

about_code_tool/tests/test_genattrib.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,13 @@ def test_check_no_about_file_not_start_with_slash(self):
5151
def test_check_have_about_file_not_start_with_slash(self):
5252
input_list = [{'Directory': '/test/', 'about_file': 'test.ABOUT'}]
5353
expected_list = [{'Directory': '/test/', 'about_file': '/test.ABOUT'}]
54-
self.assertTrue(genattrib.check_about_file_existance_and_format(input_list) == expected_list)
54+
self.assertTrue(genattrib.check_about_file_existance_and_format(input_list) == expected_list)
55+
56+
def test_update_path_to_about(self):
57+
input_list = ['/test/test1.ABOUT', '/test/test2/', 'test/test3.c']
58+
expected_list = ['/test/test1.ABOUT', '/test/test2.ABOUT', 'test/test3.c.ABOUT']
59+
output = genattrib.update_path_to_about(input_list)
60+
self.assertTrue(expected_list == output)
61+
62+
63+

0 commit comments

Comments
 (0)