Skip to content

Commit 5608055

Browse files
committed
Strip trailing whitespace to avoid creating invalid file such as
"about.c .ABOUT" Test code added.
1 parent 4cfa771 commit 5608055

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

about_code_tool/genabout.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def get_input_list(input_file):
135135
for row in csvfile:
136136
row_dict = {}
137137
for key in row:
138-
row_dict[key.lower()] = row[key]
138+
row_dict[key.lower()] = row[key].rstrip()
139139
input_list.append(row_dict)
140140
return input_list
141141

about_code_tool/tests/test_genabout.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ def test_get_input_list(self):
4141
result = gen.get_input_list(test_file)
4242
self.assertEqual(expected, result)
4343

44+
def test_get_input_with_trailing_spaces(self):
45+
gen = genabout.GenAbout()
46+
test_file = join(TESTDATA_DIR, 'test_files_for_genabout/about_with_trailling_spaces.csv')
47+
expected = [{'about_file': 'about.c',
48+
'about_resource': '.',
49+
'name': 'ABOUT tool',
50+
'version': '0.8.1'}]
51+
result = gen.get_input_list(test_file)
52+
self.assertEqual(expected, result)
53+
4454
def test_get_input_list_covert_all_keys_to_lower(self):
4555
gen = genabout.GenAbout()
4656
test_input = join(TESTDATA_DIR, 'test_files_for_genabout'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
about_file,about_resource,name,version
2+
about.c ,.,ABOUT tool,0.8.1

0 commit comments

Comments
 (0)