Skip to content

Commit e110d81

Browse files
targosMylesBorins
authored andcommitted
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. PR-URL: #30023 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Christian Clauss <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 0299767 commit e110d81

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

‎test/testpy/__init__.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
importos
3030
importre
3131
fromfunctoolsimportreduce
32+
fromioimportopen
3233

3334

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

5758
defGetCommand(self):
5859
result= [self.config.context.GetVm(self.arch, self.mode)]
59-
source=open(self.file).read()
60+
source=open(self.file, encoding='utf8').read()
6061
flags_match=FLAGS_PATTERN.search(source)
6162
ifflags_match:
6263
flags=flags_match.group(1).strip().split()

‎tools/test.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
importerrno
4646
importcopy
4747

48+
fromioimportopen
4849
fromos.pathimportjoin, dirname, abspath, basename, isdir, exists
4950
fromdatetimeimportdatetime
5051
try:
@@ -733,8 +734,8 @@ def disableCoreFiles():
733734
)
734735
os.close(fd_out)
735736
os.close(fd_err)
736-
output=open(outname).read()
737-
errors=open(errname).read()
737+
output=open(outname, encoding='utf8').read()
738+
errors=open(errname, encoding='utf8').read()
738739
CheckedUnlink(outname)
739740
CheckedUnlink(errname)
740741

0 commit comments

Comments
(0)