MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / build_tests

Function build_tests

tests/packagedcode/test_debian_copyright.py:157–177  ·  view source on GitHub ↗

Dynamically build test methods for each copyright file in `test_dir` and attach the test method to the `clazz` class.

(test_dir, clazz, prefix='test_', regen=REGEN_TEST_FIXTURES)

Source from the content-addressed store, hash-verified

155
156
157def build_tests(test_dir, clazz, prefix='test_', regen=REGEN_TEST_FIXTURES):
158 '''
159 Dynamically build test methods for each copyright file in `test_dir` and
160 attach the test method to the `clazz` class.
161 '''
162 test_data_dir = path.join(path.dirname(__file__), 'data')
163 test_dir_loc = path.join(test_data_dir, test_dir)
164 # loop through all items and attach a test method to our test class
165 for test_file in relative_walk(test_dir_loc):
166 test_loc = path.join(test_dir_loc, test_file)
167
168 test_name2 = prefix + 'detailed_' + text.python_safe_name(test_file)
169 test_method = create_test_function(
170 test_loc=test_loc,
171 expected_loc=test_loc + '-detailed.expected.yml',
172 test_name=test_name2,
173 regen=regen,
174 simplified=False,
175 )
176 # attach that method to the class
177 setattr(clazz, test_name2, test_method)
178
179
180class TestDebianCopyrightLicenseDetection(FileBasedTesting):

Callers 1

Calls 3

relative_walkFunction · 0.70
create_test_functionFunction · 0.70
joinMethod · 0.45

Tested by

no test coverage detected