37
37
# chars in the test string.
38
38
# ENCODING = 'cp1252'
39
39
40
+ # There are some issues with the test program in utf-16 but I think the logging itself works...?
41
+ # ENCODING = 'utf-16'
42
+
40
43
ENCODING = 'utf-8'
41
44
42
45
@@ -54,7 +57,7 @@ def __init__(self, sharedfile, uniquefile, name="LogStressTester", logger_delay=
54
57
self .log = None
55
58
self .use_gzip = True
56
59
self .extended_unicode = True
57
- if PY2 :
60
+ if PY2 and ENCODING != 'utf-8' :
58
61
# hopefully temporary... the problem is with stdout in the tester I think
59
62
self .extended_unicode = False
60
63
@@ -112,8 +115,8 @@ def run(self):
112
115
"the worlds largest prime number: %d" , "%d happy meals!" ]
113
116
if self .extended_unicode :
114
117
msgs .extend ([
115
- "\U0001d122 \U00024b00 Euro: \u20ac %d" ,
116
- "my favorite number is %d ①②③④⑤⑥⑦⑧!"
118
+ u "\U0001d122 \U00024b00 Euro: \u20ac %d" ,
119
+ u "my favorite number is %d ①②③④⑤⑥⑦⑧!"
117
120
])
118
121
119
122
logfuncts = [self .log .debug , self .log .info , self .log .warning , self .log .error ]
@@ -168,6 +171,9 @@ def iter_logs(iterable, missing_ok=False):
168
171
def combine_logs (combinedlog , iterable , mode = "wb" ):
169
172
""" write all lines (iterable) into a single log file. """
170
173
fp = io .open (combinedlog , mode )
174
+ if ENCODING == 'utf-16' :
175
+ import codecs
176
+ fp .write (codecs .BOM_UTF16 )
171
177
for chunk in iterable :
172
178
fp .write (chunk )
173
179
fp .close ()
@@ -255,8 +261,8 @@ def update(self, **kwargs):
255
261
def __init__ (self , output_path ):
256
262
self .output_path = output_path
257
263
self .tests = []
258
- self .client_stdout = open (os .path .join (output_path , "client_stdout.txt" ), "a" )
259
- self .client_stderr = open (os .path .join (output_path , "client_stderr.txt" ), "a" )
264
+ self .client_stdout = io . open (os .path .join (output_path , "client_stdout.txt" ), "a" , encoding = ENCODING )
265
+ self .client_stderr = io . open (os .path .join (output_path , "client_stderr.txt" ), "a" , encoding = ENCODING )
260
266
261
267
def launchPopen (self , * args , ** kwargs ):
262
268
if "stdout" not in kwargs :
0 commit comments