From 1685cd7fa7c6e5a89990f8937c4fa43ff76af779 Mon Sep 17 00:00:00 2001 From: Rouven Czerwinski Date: Fri, 27 Mar 2020 08:25:07 +0100 Subject: [PATCH] nixos/test: update test-driver.py for mypy 0.770 --- nixos/lib/test-driver/test-driver.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py index c27947bc610d..7825025893d3 100644 --- a/nixos/lib/test-driver/test-driver.py +++ b/nixos/lib/test-driver/test-driver.py @@ -6,6 +6,7 @@ from xml.sax.saxutils import XMLGenerator import _thread import atexit import base64 +import codecs import os import pathlib import ptpython.repl @@ -115,6 +116,7 @@ def create_vlan(vlan_nr: str) -> Tuple[str, str, "subprocess.Popen[bytes]", Any] fd.write("version\n") # TODO: perl version checks if this can be read from # an if not, dies. we could hang here forever. Fix it. + assert vde_process.stdout is not None vde_process.stdout.readline() if not os.path.exists(os.path.join(vde_socket, "ctl")): raise Exception("cannot start vde_switch") @@ -139,7 +141,7 @@ def retry(fn: Callable) -> None: class Logger: def __init__(self) -> None: self.logfile = os.environ.get("LOGFILE", "/dev/null") - self.logfile_handle = open(self.logfile, "wb") + self.logfile_handle = codecs.open(self.logfile, "wb") self.xml = XMLGenerator(self.logfile_handle, encoding="utf-8") self.queue: "Queue[Dict[str, str]]" = Queue(1000) @@ -739,6 +741,7 @@ class Machine: self.shell, _ = self.shell_socket.accept() def process_serial_output() -> None: + assert self.process.stdout is not None for _line in self.process.stdout: # Ignore undecodable bytes that may occur in boot menus line = _line.decode(errors="ignore").replace("\r", "").rstrip()