Skip to content

Commit 04f09fe

Browse files
committed
Fixed #446 - the test code should be green now
1 parent 0b3502d commit 04f09fe

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/attributecode/attrib.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ def generate(abouts, template=None, variables=None):
124124
# Map the license key to license name
125125
index_for_license_name_list = 0
126126
for key in lic_list:
127-
license_key_and_license_file_name[key] = about.license_file.value.keys()[index_for_license_name_list]
127+
license_key_and_license_file_name[key] = list(about.license_file.value.keys())[index_for_license_name_list]
128128
license_key_and_license_name[key] = lic_name_list[index_for_license_name_list]
129129
license_name_and_license_key[lic_name_list[index_for_license_name_list]] = key
130130
license_file_key = license_file_name_and_license_file_key[license_key_and_license_file_name[key]]
131131
license_file_key_and_license_key[license_file_key] = key
132132
index_for_license_name_list = index_for_license_name_list + 1
133-
133+
134134
# Create a license expression with license name instead of key
135135
for segment in about.license_expression.value.split():
136136
if segment in license_key_and_license_name:
@@ -163,9 +163,13 @@ def generate(abouts, template=None, variables=None):
163163
if lineno:
164164
lineno = ' at line: {}'.format(lineno)
165165
err = getattr(e, 'message', '') or ''
166+
# error = Error(
167+
# CRITICAL,
168+
# 'Template processing error {lineno}: {err}'.format(**locals()),
169+
# )
166170
error = Error(
167171
CRITICAL,
168-
'Template processing error {lineno}: {err}'.format(**locals()),
172+
'Template processing error:' + str(e),
169173
)
170174
return error, rendered
171175

@@ -232,6 +236,9 @@ def generate_and_save(abouts, output_location, template_loc=None, variables=None
232236
variables=variables
233237
)
234238

239+
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
240+
print(rendering_error)
241+
print(rendered)
235242
if rendering_error:
236243
errors.append(rendering_error)
237244

tests/test_attrib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ def test_lic_key_name_sync(self):
118118
errors, abouts = model.collect_inventory(test_file)
119119
attrib.generate_and_save(abouts, output_file, template_loc)
120120

121-
with open(output_file, 'r') as of:
121+
with open(output_file) as of:
122122
f1 = '\n'.join(of.readlines(False))
123-
with open(expected, 'r') as ef:
123+
with open(expected) as ef:
124124
f2 = '\n'.join(ef.readlines(False))
125125

126126
assert f1 == f2

0 commit comments

Comments
 (0)