mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-05 00:09:32 -04:00
Allow for multiple reference text files
This commit is contained in:
parent
0db5fabd05
commit
d4f2b842ba
@ -368,8 +368,17 @@ class AlgorithmsTest(object):
|
||||
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 @@ class TestCase(_TestCase):
|
||||
|
||||
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 @@ class TestCase(_TestCase):
|
||||
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. """
|
||||
|
Loading…
x
Reference in New Issue
Block a user