diff options
author | Daniel Coonce <danielcoonce@gmail.com> | 2020-11-16 22:15:17 -0600 |
---|---|---|
committer | Martin Michlmayr <tbm@cyrius.com> | 2021-02-02 18:13:51 +0800 |
commit | d8ed12f600bf9ca958cb9f285ceb10f5d8accbd3 (patch) | |
tree | 60bba3f9e22505c650a8cec6d85fa35277ade2b1 /test/RegressTests.py | |
parent | 8891e79de49e3b458ac7911f4dcddd676d4c95a5 (diff) | |
download | fork-ledger-d8ed12f600bf9ca958cb9f285ceb10f5d8accbd3.tar.gz fork-ledger-d8ed12f600bf9ca958cb9f285ceb10f5d8accbd3.tar.bz2 fork-ledger-d8ed12f600bf9ca958cb9f285ceb10f5d8accbd3.zip |
Make test harness more Windows compatible
Windows doesn't seem to use UTF-8 by default, so we can specify
encoding='utf-8'. Also, backslashes are confusing to regex parsers.
Diffstat (limited to 'test/RegressTests.py')
-rwxr-xr-x | test/RegressTests.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/test/RegressTests.py b/test/RegressTests.py index 9d8a7af9..7395a4c1 100755 --- a/test/RegressTests.py +++ b/test/RegressTests.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- from __future__ import print_function, unicode_literals +from io import open import sys import os @@ -40,11 +41,11 @@ if not os.path.isdir(tests) and not os.path.isfile(tests): class RegressFile(object): def __init__(self, filename): self.filename = filename - self.fd = open(self.filename) + self.fd = open(self.filename, encoding='utf-8') def transform_line(self, line): - line = re.sub('\$sourcepath', harness.sourcepath, line) - line = re.sub('\$FILE', os.path.abspath(self.filename), line) + line = line.replace('$sourcepath', harness.sourcepath) + line = line.replace('$FILE', os.path.abspath(self.filename)) return line def read_test(self): @@ -123,7 +124,7 @@ class RegressFile(object): columns=(not re.search('--columns', test['command']))) if use_stdin: - fd = open(self.filename) + fd = open(self.filename, encoding='utf-8') try: stdin = fd.read() if sys.version_info.major > 2: @@ -168,6 +169,7 @@ class RegressFile(object): if sys.platform == 'win32': process_error = [l.replace('\r\n', '\n').replace('\\', '/') for l in process_error] + test['error'] = [l.replace('\\', '/') for l in test['error']] for line in unified_diff(test['error'], process_error): index += 1 if index < 3: |