Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Allow for multiple reference text files
- Loading branch information
|
@@ -368,8 +368,17 @@ def check_results(self, results, context, params, expected): |
|
|
else: |
|
|
self.assertEqual(strhash, expected_result['hash']) |
|
|
elif 'file' == expected_result['type']: |
|
|
expected_filepath = self.filepath_from_param(expected_result) |
|
|
result_filepath = results[id] |
|
|
if isinstance(expected_result.get('name'), list): |
|
|
# test to see if any match expected |
|
|
for path in expected_result['name']: |
|
|
expected_filepath = self.filepath_from_param({'name': path}) |
|
|
if self.checkFilesEqual(expected_filepath, result_filepath): |
|
|
break |
|
|
else: |
|
|
expected_filepath = self.filepath_from_param({'name': expected_result['name'][0]}) |
|
|
else: |
|
|
expected_filepath = self.filepath_from_param(expected_result) |
|
|
|
|
|
self.assertFilesEqual(expected_filepath, result_filepath) |
|
|
elif 'directory' == expected_result['type']: |
|
|
|
@@ -196,7 +196,7 @@ def sort_by_pk_or_fid(f): |
|
|
|
|
|
return True |
|
|
|
|
|
def assertFilesEqual(self, filepath_expected, filepath_result): |
|
|
def checkFilesEqual(self, filepath_expected, filepath_result, use_asserts=False): |
|
|
with open(filepath_expected, 'r') as file_expected: |
|
|
with open(filepath_result, 'r') as file_result: |
|
|
diff = difflib.unified_diff( |
|
@@ -206,7 +206,14 @@ def assertFilesEqual(self, filepath_expected, filepath_result): |
|
|
tofile='result', |
|
|
) |
|
|
diff = list(diff) |
|
|
self.assertEqual(0, len(diff), ''.join(diff)) |
|
|
eq = not len(diff) |
|
|
if use_asserts: |
|
|
self.assertEqual(0, len(diff), ''.join(diff)) |
|
|
else: |
|
|
return eq |
|
|
|
|
|
def assertFilesEqual(self, filepath_expected, filepath_result): |
|
|
self.checkFilesEqual(filepath_expected, filepath_result, use_asserts=True) |
|
|
|
|
|
def assertDirectoriesEqual(self, dirpath_expected, dirpath_result): |
|
|
""" Checks whether both directories have the same content (recursively) and raises an assertion error if not. """ |
|
|