mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-19 00:04:52 -04:00
Add method for file comparison to testing lib
This commit is contained in:
parent
4c63c85cca
commit
6a8b4075e0
@ -27,6 +27,7 @@ __revision__ = ':%H$'
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import difflib
|
||||||
|
|
||||||
from PyQt4.QtCore import QVariant
|
from PyQt4.QtCore import QVariant
|
||||||
from qgis.core import QgsApplication, QgsFeatureRequest, QgsVectorLayer
|
from qgis.core import QgsApplication, QgsFeatureRequest, QgsVectorLayer
|
||||||
@ -140,6 +141,19 @@ class TestCase(_TestCase):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def assertFilesEqual(self, filepath_expected, filepath_result):
|
||||||
|
with open(filepath_expected, 'r') as file_expected:
|
||||||
|
with open(filepath_result, 'r') as file_result:
|
||||||
|
diff = difflib.unified_diff(
|
||||||
|
file_expected.readlines(),
|
||||||
|
file_result.readlines(),
|
||||||
|
fromfile='expected',
|
||||||
|
tofile='result',
|
||||||
|
)
|
||||||
|
diff = list(diff)
|
||||||
|
self.assertEqual(0, len(diff), ''.join(diff))
|
||||||
|
|
||||||
|
|
||||||
# Patch unittest
|
# Patch unittest
|
||||||
unittest.TestCase = TestCase
|
unittest.TestCase = TestCase
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user