python: difflib prefers unicode strings

Python 3 does not automatically convert from bytes to unicode strings
like Python 2 used to do.

This commit makes sure we pass unicode strings to difflib.unified_diff,
so that the script works on both Python 2 and 3.

Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
This commit is contained in:
Mathieu Bridon
2018-08-17 21:32:16 +02:00
committed by Dylan Baker
parent 477d4b9960
commit fc708069f7

View File

@@ -64,8 +64,9 @@ def test_output(glcpp, filename, expfile, nl_format='\n'):
stderr=subprocess.STDOUT,
stdin=subprocess.PIPE)
actual, _ = proc.communicate(f.read())
actual = actual.decode('utf-8')
with open(expfile, 'rb') as f:
with open(expfile, 'r') as f:
expected = f.read()
if actual == expected: