[U-Boot] [PATCH 07/10] test/py: Manual python3 fixes

Tom Rini
2019-10-18T20:53:35Z

- 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 need to
encode / decode our pipes in a few areas, use utf-8 for this.
- Fix a typo noticed while doing the above ("tot he" -> "to the").

Signed-off-by: Tom Rini <trini@konsulko.com>
---
test/py/conftest.py | 2 +-
test/py/multiplexed_log.py | 4 ++--
test/py/pytest.ini | 3 +++
test/py/u_boot_spawn.py | 4 ++--
4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/test/py/conftest.py b/test/py/conftest.py
index 5c19af1d5034..02b61655dcee 100644
--- a/test/py/conftest.py
+++ b/test/py/conftest.py
@@ -168,7 +168,7 @@ def pytest_configure(config):
ini_str = '[root]\n' + f.read()
ini_sio = io.StringIO(ini_str)
parser = configparser.RawConfigParser()
- parser.readfp(ini_sio)
+ parser.read_file(ini_sio)
ubconfig.buildconfig.update(parser.items('root'))

ubconfig.test_py_dir = test_py_dir
diff --git a/test/py/multiplexed_log.py b/test/py/multiplexed_log.py
index de0aacc659b8..35d95fbe0fe8 100644
--- a/test/py/multiplexed_log.py
+++ b/test/py/multiplexed_log.py
@@ -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
@@ -133,7 +133,7 @@ class RunAndLog(object):
self.logfile.write(self, msg)

try:
- p = subprocess.Popen(cmd, cwd=cwd,
+ p = subprocess.Popen(cmd, cwd=cwd, encoding="utf-8",
stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
(stdout, stderr) = p.communicate()
output = ''
diff --git a/test/py/pytest.ini b/test/py/pytest.ini
index 7e400682bf25..e93d010f1fa2 100644
--- a/test/py/pytest.ini
+++ b/test/py/pytest.ini
@@ -8,3 +8,6 @@
markers =
boardspec: U-Boot: Describes the set of boards a test can/can't run on.
buildconfigspec: U-Boot: Describes Kconfig/config-header constraints.
+ notbuildconfigspec: U-Boot: Describes required disabled Kconfig options.
+ requiredtool: U-Boot: Required host tools for a test.
+ slow: U-Boot: Specific test will run slowly.
diff --git a/test/py/u_boot_spawn.py b/test/py/u_boot_spawn.py
index b011a3e3da25..63119229f420 100644
--- a/test/py/u_boot_spawn.py
+++ b/test/py/u_boot_spawn.py
@@ -113,7 +113,7 @@ class Spawn(object):
Nothing.
"""

- os.write(self.fd, data)
+ os.write(self.fd, data.encode("utf-8"))

def expect(self, patterns):
"""Wait for the sub-process to emit specific data.
@@ -171,7 +171,7 @@ class Spawn(object):
events = self.poll.poll(poll_maxwait)
if not events:
raise Timeout()
- c = os.read(self.fd, 1024)
+ c = os.read(self.fd, 1024).decode("utf-8")
if not c:
raise EOFError()
if self.logfile_read:
--
2.17.1