@@ -98,39 +98,39 @@ def test_LicenseSymbol(self):
9898
9999 def test_python_operators_simple (self ):
100100 licensing = Licensing ()
101-
101+
102102 sym1 = LicenseSymbol ('MIT' )
103103 sym2 = LicenseSymbol ('BSD-2' )
104-
104+
105105 assert sym1 & sym2 == licensing .AND (sym1 , sym2 )
106106 assert sym1 | sym2 == licensing .OR (sym1 , sym2 )
107-
107+
108108 sym3 = LicenseWithExceptionSymbol (LicenseSymbol ("GPL-3.0-or-later" ), LicenseSymbol ("GCC-exception-3.1" ))
109-
109+
110110 # Make sure LicenseWithExceptionSymbol operation work on left and right side
111111 assert sym3 & sym1 == licensing .AND (sym3 , sym1 )
112112 assert sym1 & sym3 == licensing .AND (sym1 , sym3 )
113113 assert sym3 | sym1 == licensing .OR (sym3 , sym1 )
114114 assert sym1 | sym3 == licensing .OR (sym3 , sym1 )
115-
115+
116116 def test_boolean_expression_operators (self ):
117-
117+
118118 # Make sure LicenseWithExceptionSymbol boolean expression are set
119119 assert LicenseWithExceptionSymbol .Symbol is not None
120120 assert LicenseWithExceptionSymbol .TRUE is not None
121121 assert LicenseWithExceptionSymbol .FALSE is not None
122122 assert LicenseWithExceptionSymbol .AND is not None
123123 assert LicenseWithExceptionSymbol .OR is not None
124124 assert LicenseWithExceptionSymbol .NOT is not None
125-
125+
126126 # Make sure LicenseWithExceptionSymbol matches LicenseSymbol
127127 assert LicenseWithExceptionSymbol .Symbol == LicenseSymbol
128128 assert LicenseWithExceptionSymbol .TRUE == LicenseSymbol .TRUE
129129 assert LicenseWithExceptionSymbol .FALSE == LicenseSymbol .FALSE
130130 assert LicenseWithExceptionSymbol .AND == LicenseSymbol .AND
131131 assert LicenseWithExceptionSymbol .OR == LicenseSymbol .OR
132132 assert LicenseWithExceptionSymbol .NOT == LicenseSymbol .NOT
133-
133+
134134
135135
136136class LicensingTest (TestCase ):
@@ -2433,53 +2433,32 @@ class UtilTest(TestCase):
24332433 test_data_dir = join (dirname (__file__ ), 'data' )
24342434
24352435 def test_build_licensing (self ):
2436- test_license_index_location = join (
2437- self .test_data_dir , 'test_license_key_index.json' )
2438- with open (test_license_index_location ) as f :
2439- license_info = json .load (f )
2440- lics = [
2441- {
2442- 'key' : l .get ('license_key' , '' ),
2443- 'is_exception' : l .get ('is_exception' , '' ),
2444- } for l in license_info if l .get ('spdx_license_key' )
2445- ]
2446- syms = [LicenseSymbol (** l ) for l in lics ]
2447- expected = Licensing (syms )
2448-
2449- test_license_index = get_license_index (
2450- license_index_location = test_license_index_location )
2436+ test_license_index_location = join (self .test_data_dir , "test_license_key_index.json" )
2437+ test_license_index = get_license_index (license_index_location = test_license_index_location )
24512438 result = build_licensing (test_license_index )
24522439
2453- assert result .known_symbols == expected .known_symbols
2454- assert result .known_symbols_lowercase == expected .known_symbols_lowercase
2455- # Ensure deprecated licenses are not loaded
2456- assert 'aladdin-md5' not in result .known_symbols
2457- assert 'aladdin-md5' not in result .known_symbols_lowercase
2440+ known_symbols = set (result .known_symbols .keys ())
2441+ known_symbols_lowercase = set (result .known_symbols_lowercase .keys ())
2442+ expected_symbols = {"389-exception" , "3com-microcode" , "3dslicer-1.0" , "aladdin-md5" }
24582443
2459- def test_build_spdx_licensing (self ):
2460- test_license_index_location = join (
2461- self .test_data_dir , 'test_license_key_index.json' )
2462- with open (test_license_index_location ) as f :
2463- license_info = json .load (f )
2464- lics = [
2465- {
2466- 'key' : l .get ('spdx_license_key' , '' ),
2467- 'aliases' : l .get ('other_spdx_license_keys' , '' ),
2468- 'is_exception' : l .get ('is_exception' , '' ),
2469- } for l in license_info if l .get ('spdx_license_key' )
2470- ]
2471- syms = [LicenseSymbol (** l ) for l in lics ]
2472- expected = Licensing (syms )
2444+ assert known_symbols == expected_symbols
2445+ assert known_symbols_lowercase == {sym .lower () for sym in expected_symbols }
24732446
2474- test_license_index = get_license_index (
2475- license_index_location = test_license_index_location )
2447+ def test_build_spdx_licensing (self ):
2448+ test_license_index_location = join (self .test_data_dir , "test_license_key_index.json" )
2449+ test_license_index = get_license_index (license_index_location = test_license_index_location )
24762450 result = build_spdx_licensing (test_license_index )
24772451
2478- assert result .known_symbols == expected .known_symbols
2479- assert result .known_symbols_lowercase == expected .known_symbols_lowercase
2480- # Ensure deprecated licenses are not loaded
2481- assert 'aladdin-md5' not in result .known_symbols
2482- assert 'aladdin-md5' not in result .known_symbols_lowercase
2452+ known_symbols = set (result .known_symbols .keys ())
2453+ known_symbols_lowercase = set (result .known_symbols_lowercase .keys ())
2454+ expected_symbols = {
2455+ "389-exception" ,
2456+ "LicenseRef-scancode-3com-microcode" ,
2457+ "LicenseRef-scancode-3dslicer-1.0" ,
2458+ }
2459+
2460+ assert known_symbols == expected_symbols
2461+ assert known_symbols_lowercase == {sym .lower () for sym in expected_symbols }
24832462
24842463 def test_get_license_key_info (self ):
24852464 test_license_index_location = join (
0 commit comments