Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: fix test runner for Python 3 on Windows
Explicitly open files with utf8 encoding, otherwise the system could use
another encoding such as latin1 by default.
  • Loading branch information
targos committed Oct 18, 2019
commit a6d74ec9b250b1b1ee396ccfbd571e82b01e478e
3 changes: 2 additions & 1 deletion test/testpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import os
import re
from functools import reduce
from io import open


FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
Expand Down Expand Up @@ -56,7 +57,7 @@ def GetName(self):

def GetCommand(self):
result = [self.config.context.GetVm(self.arch, self.mode)]
source = open(self.file).read()
source = open(self.file, encoding='utf8').read()
flags_match = FLAGS_PATTERN.search(source)
if flags_match:
flags = flags_match.group(1).strip().split()
Expand Down
5 changes: 3 additions & 2 deletions tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import errno
import copy

from io import open
from os.path import join, dirname, abspath, basename, isdir, exists
from datetime import datetime
try:
Expand Down Expand Up @@ -733,8 +734,8 @@ def disableCoreFiles():
)
os.close(fd_out)
os.close(fd_err)
output = open(outname).read()
errors = open(errname).read()
output = open(outname, encoding='utf8').read()
errors = open(errname, encoding='utf8').read()
CheckedUnlink(outname)
CheckedUnlink(errname)

Expand Down