Skip to content
Permalink
Browse files

Add method for file comparison to testing lib

  • Loading branch information
m-kuhn committed Feb 21, 2016
1 parent 4c63c85 commit 6a8b4075e0d90d65d34d21fb0eea50cd743cf6b2
Showing with 14 additions and 0 deletions.
  1. +14 −0 python/testing/__init__.py
@@ -27,6 +27,7 @@

import os
import sys
import difflib

from PyQt4.QtCore import QVariant
from qgis.core import QgsApplication, QgsFeatureRequest, QgsVectorLayer
@@ -140,6 +141,19 @@ def assertLayersEqual(self, layer_expected, layer_result, **kwargs):
)
)

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
unittest.TestCase = TestCase

0 comments on commit 6a8b407

Please sign in to comment.
You can’t perform that action at this time.