From 9611041ef54b09eb764ed72d95c3111ce52fe984 Mon Sep 17 00:00:00 2001 From: K900 Date: Tue, 19 Oct 2021 16:29:19 +0300 Subject: [PATCH] nixos/lib/test-driver: set defaults in __init__ instead of class level Just a minor code style nit to avoid potential footguns --- nixos/lib/test-driver/test-driver.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py index f2e7bf3c1d5b..3ee8b3227c61 100755 --- a/nixos/lib/test-driver/test-driver.py +++ b/nixos/lib/test-driver/test-driver.py @@ -405,14 +405,14 @@ class Machine: keep_vm_state: bool allow_reboot: bool - process: Optional[subprocess.Popen] = None - pid: Optional[int] = None - monitor: Optional[socket.socket] = None - shell: Optional[socket.socket] = None + process: Optional[subprocess.Popen] + pid: Optional[int] + monitor: Optional[socket.socket] + shell: Optional[socket.socket] serial_thread: Optional[threading.Thread] - booted: bool = False - connected: bool = False + booted: bool + connected: bool # Store last serial console lines for use # of wait_for_console_text last_lines: Queue = Queue() @@ -445,8 +445,15 @@ class Machine: self.cleanup_statedir() self.state_dir.mkdir(mode=0o700, exist_ok=True) + self.process = None + self.pid = None + self.monitor = None + self.shell = None self.serial_thread = None + self.booted = False + self.connected = False + @staticmethod def create_startcommand(args: Dict[str, str]) -> StartCommand: rootlog.warning(