mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-07-05 13:52:14 +00:00
test/py: Manual python3 fixes
- Modern pytest is more visible in telling us about parameters that we had not described, so describe a few more. - ConfigParser.readfp(...) is now configparser.read_file(...) - As part of the "strings vs bytes" conversions in Python 3, we use the default encoding/decoding of utf-8 but in some places tell Python to replace problematic conversions rather than throw a fatal error. - Fix a typo noticed while doing the above ("tot he" -> "to the"). - As suggested by Stephen, re-alphabetize the import list - Per Heinrich, replace how we write contents in test_fit.py Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Stephen Warren <swarren@nvidia.com> Tested-by: Simon Glass <sjg@chromium.org> [on sandbox] Signed-off-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
fe1193e254
commit
fd31fc172c
5 changed files with 19 additions and 12 deletions
|
@ -51,7 +51,7 @@ class LogfileStream(object):
|
|||
"""Write data to the log stream.
|
||||
|
||||
Args:
|
||||
data: The data to write tot he file.
|
||||
data: The data to write to the file.
|
||||
implicit: Boolean indicating whether data actually appeared in the
|
||||
stream, or was implicitly generated. A valid use-case is to
|
||||
repeat a shell prompt at the start of each separate log
|
||||
|
@ -64,7 +64,8 @@ class LogfileStream(object):
|
|||
|
||||
self.logfile.write(self, data, implicit)
|
||||
if self.chained_file:
|
||||
self.chained_file.write(data)
|
||||
# Chained file is console, convert things a little
|
||||
self.chained_file.write((data.encode('ascii', 'replace')).decode())
|
||||
|
||||
def flush(self):
|
||||
"""Flush the log stream, to ensure correct log interleaving.
|
||||
|
@ -136,6 +137,10 @@ class RunAndLog(object):
|
|||
p = subprocess.Popen(cmd, cwd=cwd,
|
||||
stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
(stdout, stderr) = p.communicate()
|
||||
if stdout is not None:
|
||||
stdout = stdout.decode('utf-8')
|
||||
if stderr is not None:
|
||||
stderr = stderr.decode('utf-8')
|
||||
output = ''
|
||||
if stdout:
|
||||
if stderr:
|
||||
|
@ -215,7 +220,7 @@ class Logfile(object):
|
|||
Nothing.
|
||||
"""
|
||||
|
||||
self.f = open(fn, 'wt')
|
||||
self.f = open(fn, 'wt', encoding='utf-8')
|
||||
self.last_stream = None
|
||||
self.blocks = []
|
||||
self.cur_evt = 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue