Skip to content
Browse files

Allow for multiple reference text files

  • Loading branch information
nyalldawson committed Feb 8, 2021
1 parent 0db5fab commit d4f2b842ba51b052a20bf086a303bda4e132d6ab
Showing with 19 additions and 3 deletions.
  1. +10 −1 python/plugins/processing/tests/
  2. +9 −2 python/testing/
@@ -368,8 +368,17 @@ def check_results(self, results, context, params, expected):
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):
expected_filepath = self.filepath_from_param({'name': expected_result['name'][0]})
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):
diff = list(diff)
self.assertEqual(0, len(diff), ''.join(diff))
eq = not len(diff)
if use_asserts:
self.assertEqual(0, len(diff), ''.join(diff))
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. """

0 comments on commit d4f2b84

Please sign in to comment.