Explicitly decode test files as UTF-8

This way the test does not fail if run in a non-UTF-8 locale.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2017-09-18 13:02:03 +02:00
parent ed9d7f69a6
commit 2efc4d8561

View File

@ -27,10 +27,10 @@ class CompsWrapperTest(unittest.TestCase):
self.file = tempfile.NamedTemporaryFile(prefix='comps-wrapper-test-')
def assertFilesEqual(self, fn1, fn2):
with open(fn1) as f1:
lines1 = f1.read().splitlines()
with open(fn2) as f2:
lines2 = f2.read().splitlines()
with open(fn1, 'rb') as f1:
lines1 = f1.read().decode('utf-8').splitlines()
with open(fn2, 'rb') as f2:
lines2 = f2.read().decode('utf-8').splitlines()
diff = '\n'.join(difflib.unified_diff(lines1, lines2,
fromfile='EXPECTED', tofile='ACTUAL'))
self.assertEqual(diff, '', 'Files differ:\n' + diff)