1414# limitations under the License.
1515# ============================================================================
1616
17- # We require Python 2.6 or later
1817from __future__ import print_function
1918
2019import sys
2625
2726from about_code_tool import about
2827
29- TESTDATA_PATH = join (abspath (dirname (__file__ )), 'testdata' )
28+ TESTDATA_DIR = join (abspath (dirname (__file__ )), 'testdata' )
3029
3130
3231class CommandLineTest (unittest .TestCase ):
@@ -316,15 +315,15 @@ def test_handles_last_line_is_not_a_continuation_line(self):
316315 self .assertTrue (len (warnings ) == 1 , 'This should throw ONLY 1 warning.' )
317316
318317 def test_normalize_dupe_field_names (self ):
319- about_file = about .AboutFile (join (TESTDATA_PATH , 'parser_tests/dupe_field_name.ABOUT' ))
318+ about_file = about .AboutFile (join (TESTDATA_DIR , 'parser_tests/dupe_field_name.ABOUT' ))
320319 expected_warnings = [about .IGNORED , 'Apache HTTP Server' ]
321320 self .assertTrue (len (about_file .warnings ) == 1 , 'This should throw one warning' )
322321 for w in about_file .warnings :
323322 self .assertEqual (expected_warnings [0 ], w .code )
324323 self .assertEqual (expected_warnings [1 ], w .field_value )
325324
326325 def test_normalize_lowercase (self ):
327- about_file = about .AboutFile (join (TESTDATA_PATH , 'parser_tests/upper_field_names.ABOUT' ))
326+ about_file = about .AboutFile (join (TESTDATA_DIR , 'parser_tests/upper_field_names.ABOUT' ))
328327 expected = {'name' : 'Apache HTTP Server\n this is a continuation' ,
329328 'home_url' : 'http://httpd.apache.org' ,
330329 'download_url' : 'http://archive.apache.org/dist/httpd/httpd-2.4.3.tar.gz' ,
@@ -338,11 +337,11 @@ def test_normalize_lowercase(self):
338337 self .assertTrue (all (item in about_file .validated_fields .items () for item in expected .items ()))
339338
340339 def test_validate_about_ref_testing_the_about_resource_field_is_present (self ):
341- about_file = about .AboutFile (join (TESTDATA_PATH , 'parser_tests/about_resource_field_present.ABOUT' ))
340+ about_file = about .AboutFile (join (TESTDATA_DIR , 'parser_tests/about_resource_field_present.ABOUT' ))
342341 self .assertEquals (about_file .about_resource , 'about_resource.c' , 'the about_resource was not detected' )
343342
344343 def test_validate_about_ref_no_about_ref_key (self ):
345- about_file = about .AboutFile (join (TESTDATA_PATH , 'parser_tests/.ABOUT' ))
344+ about_file = about .AboutFile (join (TESTDATA_DIR , 'parser_tests/.ABOUT' ))
346345 # We do not need 'about_resource' now, so no error should be thrown.
347346 # expected_errors = [about.VALUE, 'about_resource']
348347 self .assertTrue (len (about_file .errors ) == 0 , 'No error should be thrown.' )
@@ -351,23 +350,23 @@ def test_validate_about_ref_no_about_ref_key(self):
351350 self.assertEqual(expected_errors[1], w.field_name)'''
352351
353352 def test_validate_about_resource_error_thrown_when_file_referenced_by_about_file_does_not_exist (self ):
354- about_file = about .AboutFile (join (TESTDATA_PATH , 'parser_tests/missing_about_ref.ABOUT' ))
353+ about_file = about .AboutFile (join (TESTDATA_DIR , 'parser_tests/missing_about_ref.ABOUT' ))
355354 expected_errors = [about .FILE , 'about_resource' ]
356355 self .assertTrue (len (about_file .errors ) == 1 , 'This should throw 1 error' )
357356 for w in about_file .errors :
358357 self .assertEqual (expected_errors [0 ], w .code )
359358 self .assertEqual (expected_errors [1 ], w .field_name )
360359
361360 def test_validate_mand_fields_name_and_version_and_about_resource_present (self ):
362- about_file = about .AboutFile (join (TESTDATA_PATH , 'parser_tests/missing_mand.ABOUT' ))
361+ about_file = about .AboutFile (join (TESTDATA_DIR , 'parser_tests/missing_mand.ABOUT' ))
363362 expected_errors = [(about .VALUE , 'name' ),
364363 (about .VALUE , 'version' ), ]
365364 self .assertTrue (len (about_file .errors ) == 2 , 'This should throw 2 errors.' )
366365 for i , w in enumerate (about_file .errors ):
367366 self .assertEqual (expected_errors [i ][0 ], w .code )
368367 self .assertEqual (expected_errors [i ][1 ], w .field_name )
369368
370- about_file = about .AboutFile (join (TESTDATA_PATH , 'parser_tests/missing_mand_values.ABOUT' ))
369+ about_file = about .AboutFile (join (TESTDATA_DIR , 'parser_tests/missing_mand_values.ABOUT' ))
371370 expected_errors = [(about .VALUE , 'name' ),
372371 (about .VALUE , 'version' )]
373372 self .assertTrue (len (about_file .errors ) == 2 , 'This should throw 2 errors.' )
@@ -376,7 +375,7 @@ def test_validate_mand_fields_name_and_version_and_about_resource_present(self):
376375 self .assertEqual (expected_errors [i ][1 ], w .field_name )
377376
378377 def test_validate_optional_file_field_value (self ):
379- about_file = about .AboutFile (join (TESTDATA_PATH , 'parser_tests/about_file_ref.c.ABOUT' ))
378+ about_file = about .AboutFile (join (TESTDATA_DIR , 'parser_tests/about_file_ref.c.ABOUT' ))
380379 expected_warnings = [about .VALUE , 'notice_file' ]
381380 self .assertTrue (len (about_file .warnings ) == 1 , 'This should throw one warning' )
382381 for w in about_file .warnings :
@@ -461,27 +460,27 @@ def test_validate_is_ascii_key(self):
461460 self .assertFalse (about_file .check_is_ascii (u'測試' ))
462461
463462 def test_validate_is_ascii_value (self ):
464- about_file = about .AboutFile (join (TESTDATA_PATH , 'filesfields/non_ascii_field.about' ))
463+ about_file = about .AboutFile (join (TESTDATA_DIR , 'filesfields/non_ascii_field.about' ))
465464 expected_errors = [about .ASCII ]
466465 self .assertTrue (len (about_file .errors ) == 1 , 'This should throw 1 error' )
467466 self .assertEqual (about_file .errors [0 ].code , expected_errors [0 ])
468467
469468 def test_validate_spdx_licenses (self ):
470- about_file = about .AboutFile (join (TESTDATA_PATH , 'spdx_licenses/incorrect_spdx.about' ))
469+ about_file = about .AboutFile (join (TESTDATA_DIR , 'spdx_licenses/incorrect_spdx.about' ))
471470 expected_errors = [about .SPDX ]
472471 self .assertTrue (len (about_file .errors ) == 1 , 'This should throw 1 error' )
473472 for w in about_file .errors :
474473 self .assertEqual (expected_errors [0 ], w .code )
475474
476475 def test_validate_spdx_licenses1 (self ):
477- about_file = about .AboutFile (join (TESTDATA_PATH , 'spdx_licenses/invalid_multi_format_spdx.ABOUT' ))
476+ about_file = about .AboutFile (join (TESTDATA_DIR , 'spdx_licenses/invalid_multi_format_spdx.ABOUT' ))
478477 expected_errors = [about .SPDX ]
479478 self .assertTrue (len (about_file .errors ) == 1 , 'This should throw 1 error' )
480479 for w in about_file .errors :
481480 self .assertEqual (expected_errors [0 ], w .code )
482481
483482 def test_validate_spdx_licenses2 (self ):
484- about_file = about .AboutFile (join (TESTDATA_PATH , 'spdx_licenses/invalid_multi_name.ABOUT' ))
483+ about_file = about .AboutFile (join (TESTDATA_DIR , 'spdx_licenses/invalid_multi_name.ABOUT' ))
485484 expected_errors = [about .SPDX ]
486485 # The test case is: license_spdx: Something and SomeOtherThings
487486 # Thus, it should throw 2 errors: 'Something', 'SomeOtherThings'
@@ -490,21 +489,21 @@ def test_validate_spdx_licenses2(self):
490489 self .assertEqual (expected_errors [0 ], w .code )
491490
492491 def test_validate_spdx_licenses3 (self ):
493- about_file = about .AboutFile (join (TESTDATA_PATH , 'spdx_licenses/lower_case_spdx.ABOUT' ))
492+ about_file = about .AboutFile (join (TESTDATA_DIR , 'spdx_licenses/lower_case_spdx.ABOUT' ))
494493 expected_warnings = [about .SPDX ]
495494 self .assertTrue (len (about_file .warnings ) == 1 , 'This should throw one warning' )
496495 for w in about_file .warnings :
497496 self .assertEqual (expected_warnings [0 ], w .code )
498497
499498 def test_validate_not_supported_date_format (self ):
500- about_file = about .AboutFile (join (TESTDATA_PATH , 'DateTest/non-supported_date_format.ABOUT' ))
499+ about_file = about .AboutFile (join (TESTDATA_DIR , 'DateTest/non-supported_date_format.ABOUT' ))
501500 expected_warnings = [about .DATE ]
502501 self .assertTrue (len (about_file .warnings ) == 1 , 'This should throw one warning' )
503502 for w in about_file .warnings :
504503 self .assertEqual (expected_warnings [0 ], w .code )
505504
506505 def test_validate_supported_date_format (self ):
507- about_file = about .AboutFile (join (TESTDATA_PATH , 'DateTest/supported_date_format.ABOUT' ))
506+ about_file = about .AboutFile (join (TESTDATA_DIR , 'DateTest/supported_date_format.ABOUT' ))
508507 self .assertTrue (len (about_file .warnings ) == 0 , 'This should not throw warning.' )
509508
510509 def test_remove_blank_lines_and_field_spaces (self ):
@@ -554,8 +553,8 @@ def test_remove_blank_lines_and_no_colon_fields(self):
554553 def test_generate_attribution (self ):
555554 expected = (u'notice_text:version:2.4.3about_resource:httpd-2.4.3.tar.gz'
556555 'name:Apache HTTP Serverlicense_text:' )
557- about_collector = about .Collector (join (TESTDATA_PATH , 'attrib/attrib.ABOUT' ))
558- result = about_collector .generate_attribution (join (TESTDATA_PATH , 'attrib/test.template' ))
556+ about_collector = about .Collector (join (TESTDATA_DIR , 'attrib/attrib.ABOUT' ))
557+ result = about_collector .generate_attribution (join (TESTDATA_DIR , 'attrib/test.template' ))
559558 self .assertEqual (expected , result )
560559
561560 def test_license_text_extracted_from_license_text_file (self ):
@@ -564,36 +563,36 @@ def test_license_text_extracted_from_license_text_file(self):
564563
565564* Email [email protected] for any questions''' 566565
567- about_file = about .AboutFile (join (TESTDATA_PATH , 'attrib/license_text.ABOUT' ))
566+ about_file = about .AboutFile (join (TESTDATA_DIR , 'attrib/license_text.ABOUT' ))
568567 license_text = about_file .license_text ()
569568 self .assertEqual (license_text , expected )
570569
571570 def test_notice_text_extacted_from_notice_text_file (self ):
572571 expected = '''Test component is released to Public Domain.'''
573- about_file = about .AboutFile (join (TESTDATA_PATH , 'attrib/license_text.ABOUT' ))
572+ about_file = about .AboutFile (join (TESTDATA_DIR , 'attrib/license_text.ABOUT' ))
574573 notice_text = about_file .notice_text ()
575574 self .assertEqual (notice_text , expected )
576575
577576 def test_license_text_returns_empty_string_when_no_field_present (self ):
578577 expected = ''
579- about_file = about .AboutFile (join (TESTDATA_PATH , 'attrib/no_text_file_field.ABOUT' ))
578+ about_file = about .AboutFile (join (TESTDATA_DIR , 'attrib/no_text_file_field.ABOUT' ))
580579 license_text = about_file .license_text ()
581580 self .assertEqual (license_text , expected )
582581
583582 def test_notice_text_returns_empty_string_when_no_field_present (self ):
584583 expected = ''
585- about_file = about .AboutFile (join (TESTDATA_PATH , 'attrib/no_text_file_field.ABOUT' ))
584+ about_file = about .AboutFile (join (TESTDATA_DIR , 'attrib/no_text_file_field.ABOUT' ))
586585 notice_text = about_file .notice_text ()
587586 self .assertEqual (notice_text , expected )
588587
589588 def test_license_text_returns_empty_string_when_ref_file_doesnt_exist (self ):
590589 expected = ''
591- about_file = about .AboutFile (join (TESTDATA_PATH , 'attrib/missing_notice_license_files.ABOUT' ))
590+ about_file = about .AboutFile (join (TESTDATA_DIR , 'attrib/missing_notice_license_files.ABOUT' ))
592591 license_text = about_file .license_text ()
593592 self .assertEqual (license_text , expected )
594593
595594 def test_notice_text_returns_empty_string_when_ref_file_doesnt_exist (self ):
596595 expected = ''
597- about_file = about .AboutFile (join (TESTDATA_PATH , 'attrib/missing_notice_license_files.ABOUT' ))
596+ about_file = about .AboutFile (join (TESTDATA_DIR , 'attrib/missing_notice_license_files.ABOUT' ))
598597 notice_text = about_file .notice_text ()
599598 self .assertEqual (notice_text , expected )
0 commit comments