@@ -162,7 +162,7 @@ def test_check_file_names_with_dupes_return_errors(self):
162162 Error (
163163 CRITICAL ,
164164 "Duplicate files: 'some/PAth' and 'some/path' have the same case-insensitive file name" )
165- ]
165+ ]
166166 assert expected == result
167167
168168 def test_check_file_names_without_dupes_return_no_error (self ):
@@ -196,9 +196,11 @@ def test_check_file_names_with_invalid_chars_return_errors(self):
196196 ]
197197 import sys
198198 if sys .version_info [0 ] < 3 : # python2
199- expected = [Error (CRITICAL , b"Invalid characters '\xe9 \xe8 ' in file name at: 'Accessibilit\xe9 / p\xe9 rim\xe8 tre'" )]
199+ expected = [Error (
200+ CRITICAL , b"Invalid characters '\xe9 \xe8 ' in file name at: 'Accessibilit\xe9 / p\xe9 rim\xe8 tre'" )]
200201 else :
201- expected = [Error (CRITICAL , "Invalid characters ':' in file name at: 'locations/in:valid'" )]
202+ expected = [
203+ Error (CRITICAL , "Invalid characters ':' in file name at: 'locations/in:valid'" )]
202204 result = util .check_file_names (paths )
203205
204206 assert expected [0 ].message == result [0 ].message
@@ -272,7 +274,8 @@ def test_get_about_locations(self):
272274 assert expected == result
273275
274276 def test_get_locations_can_yield_a_single_file (self ):
275- test_file = get_test_loc ('test_util/about_locations/file with_spaces.ABOUT' )
277+ test_file = get_test_loc (
278+ 'test_util/about_locations/file with_spaces.ABOUT' )
276279 result = list (util .get_locations (test_file ))
277280 assert 1 == len (result )
278281
@@ -351,13 +354,15 @@ def test_format_about_dict_output(self):
351354
352355 def test_load_csv_microsoft_utf_8 (self ):
353356 test_file = get_test_loc ('test_util/csv/test_ms_utf8.csv' )
354- expected = [dict ([(u'about_resource' , u'/myFile' ), (u'name' , u'myName' )])]
357+ expected = [
358+ dict ([(u'about_resource' , u'/myFile' ), (u'name' , u'myName' )])]
355359 result = util .load_csv (test_file )
356360 assert expected == result
357361
358362 def test_load_csv_utf_8 (self ):
359363 test_file = get_test_loc ('test_util/csv/test_utf8.csv' )
360- expected = [dict ([(u'about_resource' , u'/myFile' ), (u'name' , u'\u540d ' )])]
364+ expected = [
365+ dict ([(u'about_resource' , u'/myFile' ), (u'name' , u'\u540d ' )])]
361366 result = util .load_csv (test_file )
362367 assert expected == result
363368
@@ -409,7 +414,7 @@ def test_load_non_list_json(self):
409414 'about_resource' : '.' ,
410415 'name' : 'AboutCode' ,
411416 'version' : '0.11.0'
412- }]
417+ }]
413418 result = util .load_json (test_file )
414419 assert expected == result
415420
@@ -420,7 +425,7 @@ def test_load_non_list_json2(self):
420425 'about_resource' : '.' ,
421426 'name' : 'AboutCode' ,
422427 'version' : '0.11.0'
423- }]
428+ }]
424429 result = util .load_json (test_file )
425430 assert expected == result
426431
@@ -450,7 +455,7 @@ def test_load_json_from_scancode(self):
450455 'dirs_count' : 0 ,
451456 'size_count' : 0 ,
452457 'scan_errors' : []
453- }]
458+ }]
454459 result = util .load_scancode_json (test_file )
455460 assert expected == result
456461
@@ -497,7 +502,7 @@ def test_load_yaml_about_file_raise_exception_on__duplicate(self):
497502 try :
498503 saneyaml .load (test , allow_duplicate_keys = False )
499504 self .fail ('Exception not raised' )
500- except saneyaml .UnsupportedYamlFeatureError as e :
505+ except saneyaml .UnsupportedYamlFeatureError as e :
501506 assert 'Duplicate key in YAML source: notes' == str (e )
502507
503508 def test_load_yaml_about_file_raise_exception_on_invalid_yaml_ignore_non_key_line (self ):
@@ -532,7 +537,7 @@ def test_load_yaml_about_file_with_multiline(self):
532537 try :
533538 saneyaml .load (test , allow_duplicate_keys = False )
534539 self .fail ('Exception not raised' )
535- except saneyaml .UnsupportedYamlFeatureError as e :
540+ except saneyaml .UnsupportedYamlFeatureError as e :
536541 # notes: exceptio is rasied only for the first dupe
537542 assert 'Duplicate key in YAML source: owner' == str (e )
538543
@@ -558,7 +563,8 @@ def test_ungroup_licenses(self):
558563 u'https://enterprise.dejacode.com/urn/?urn=urn:dje:license:mit' ,
559564 u'https://enterprise.dejacode.com/urn/?urn=urn:dje:license:bsd-new' ]
560565 expected_spdx = [u'MIT' , u'BSD-3-Clause' ]
561- lic_key , lic_name , lic_file , lic_url , spdx_lic_key , lic_score , _matched_text = util .ungroup_licenses (about )
566+ lic_key , lic_name , lic_file , lic_url , spdx_lic_key , lic_score , _matched_text = util .ungroup_licenses (
567+ about )
562568 assert expected_lic_key == lic_key
563569 assert expected_lic_name == lic_name
564570 assert expected_lic_file == lic_file
@@ -648,3 +654,17 @@ def test_copy_file_with_dir(self):
648654 assert len (licenses ) == len (files_list )
649655 for license in licenses :
650656 assert license in files_list
657+
658+ def test_strip_inventory_value (self ):
659+ test = [{'about_resource' : 'empty_newlines.rpm\n \n ' , 'name' : 'empty_newlines.rpm' },
660+ {'about_resource' : 'spaces_after.rpm ' ,
661+ 'name' : 'spaces_after.rpm ' },
662+ {'about_resource' : 'value_after_newline\n 123.rpm ' ,
663+ 'name' : 'value_after' }]
664+ expected = [{'about_resource' : 'empty_newlines.rpm' , 'name' : 'empty_newlines.rpm' },
665+ {'about_resource' : 'spaces_after.rpm' ,
666+ 'name' : 'spaces_after.rpm' },
667+ {'about_resource' : 'value_after_newline\n 123.rpm' ,
668+ 'name' : 'value_after' }]
669+ stripped_result = util .strip_inventory_value (test )
670+ assert stripped_result == expected
0 commit comments